From 9f219c79aa145ed0b16f44e6b4486b4928083a71 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sun, 13 Feb 2005 07:34:17 +0000 Subject: Fix PR506: * Use error returned from Archive::OpenAndLoad * Make sure only std::string is thrown so it gets caught and printed. llvm-svn: 20147 --- llvm/tools/llvm-ranlib/llvm-ranlib.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'llvm/tools/llvm-ranlib/llvm-ranlib.cpp') diff --git a/llvm/tools/llvm-ranlib/llvm-ranlib.cpp b/llvm/tools/llvm-ranlib/llvm-ranlib.cpp index cc86fba953d..70d5cf8abf9 100644 --- a/llvm/tools/llvm-ranlib/llvm-ranlib.cpp +++ b/llvm/tools/llvm-ranlib/llvm-ranlib.cpp @@ -64,12 +64,14 @@ int main(int argc, char **argv) { // Make sure it exists, we don't create empty archives if (!ArchivePath.exists()) - throw "Archive file does not exist"; + throw std::string("Archive file does not exist"); - std::auto_ptr AutoArchive(Archive::OpenAndLoad(ArchivePath)); + std::string err_msg; + std::auto_ptr + AutoArchive(Archive::OpenAndLoad(ArchivePath,&err_msg)); Archive* TheArchive = AutoArchive.get(); - - assert(TheArchive && "Unable to instantiate the archive"); + if (!TheArchive) + throw err_msg; TheArchive->writeToDisk(true, false, false ); -- cgit v1.2.3