Implement error handling in OpenAndLoad* functions so the Linker can handle it.
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 02:59:03 +0000 (02:59 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 02:59:03 +0000 (02:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18853 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Archive/ArchiveReader.cpp
lib/Bytecode/Archive/ArchiveReader.cpp

index b00487f0ded9a20a0ae0c02ec23eb8c61103e3bb..a813371958d4f0b482e3ea6c6bfdd86aab96f430 100644 (file)
@@ -280,13 +280,17 @@ Archive::loadArchive() {
 
 // Open and completely load the archive file.
 Archive*
-Archive::OpenAndLoad(const sys::Path& file) {
-
-  Archive* result = new Archive(file, true);
-
-  result->loadArchive();
-  
-  return result;
+Archive::OpenAndLoad(const sys::Path& file, std::string* ErrorMessage) {
+  try {
+    Archive* result = new Archive(file, true);
+    result->loadArchive();
+    return result;
+  } catch (const std::string& msg) {
+    if (ErrorMessage) {
+      *ErrorMessage = msg;
+    }
+    return 0;
+  }
 }
 
 // Get all the bytecode modules from the archive
@@ -371,12 +375,17 @@ Archive::loadSymbolTable() {
 
 // Open the archive and load just the symbol tables
 Archive*
-Archive::OpenAndLoadSymbols(const sys::Path& file) {
-  Archive* result = new Archive(file, true);
-
-  result->loadSymbolTable();
-
-  return result;
+Archive::OpenAndLoadSymbols(const sys::Path& file, std::string* ErrorMessage) {
+  try {
+    Archive* result = new Archive(file, true);
+    result->loadSymbolTable();
+    return result;
+  } catch (const std::string& msg) {
+    if (ErrorMessage) {
+      *ErrorMessage = msg;
+    }
+    return 0;
+  }
 }
 
 // Look up one symbol in the symbol table and return a ModuleProvider for the
index b00487f0ded9a20a0ae0c02ec23eb8c61103e3bb..a813371958d4f0b482e3ea6c6bfdd86aab96f430 100644 (file)
@@ -280,13 +280,17 @@ Archive::loadArchive() {
 
 // Open and completely load the archive file.
 Archive*
-Archive::OpenAndLoad(const sys::Path& file) {
-
-  Archive* result = new Archive(file, true);
-
-  result->loadArchive();
-  
-  return result;
+Archive::OpenAndLoad(const sys::Path& file, std::string* ErrorMessage) {
+  try {
+    Archive* result = new Archive(file, true);
+    result->loadArchive();
+    return result;
+  } catch (const std::string& msg) {
+    if (ErrorMessage) {
+      *ErrorMessage = msg;
+    }
+    return 0;
+  }
 }
 
 // Get all the bytecode modules from the archive
@@ -371,12 +375,17 @@ Archive::loadSymbolTable() {
 
 // Open the archive and load just the symbol tables
 Archive*
-Archive::OpenAndLoadSymbols(const sys::Path& file) {
-  Archive* result = new Archive(file, true);
-
-  result->loadSymbolTable();
-
-  return result;
+Archive::OpenAndLoadSymbols(const sys::Path& file, std::string* ErrorMessage) {
+  try {
+    Archive* result = new Archive(file, true);
+    result->loadSymbolTable();
+    return result;
+  } catch (const std::string& msg) {
+    if (ErrorMessage) {
+      *ErrorMessage = msg;
+    }
+    return 0;
+  }
 }
 
 // Look up one symbol in the symbol table and return a ModuleProvider for the