Improve error message.
authorRui Ueyama <ruiu@google.com>
Tue, 3 Jun 2014 08:40:49 +0000 (08:40 +0000)
committerRui Ueyama <ruiu@google.com>
Tue, 3 Jun 2014 08:40:49 +0000 (08:40 +0000)
Previously the parser always printed out an error message followed
by "Invalid file type" even if the file type is correct.

llvm-svn: 210093

lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp

index c562c63..4752097 100644 (file)
@@ -1079,9 +1079,9 @@ private:
     stream.flush();
     // Print error message if error.
     if (parseFailed) {
-      llvm::errs() << "Failed to parse '" << directives << "'\n"
-                   << "Reason: " << errorMessage;
-      return make_error_code(llvm::object::object_error::invalid_file_type);
+      auto msg = Twine("Failed to parse '") + directives + "'\n"
+        + "Reason: " + errorMessage;
+      return make_dynamic_error_code(msg);
     }
     if (!errorMessage.empty()) {
       llvm::errs() << "lld warning: " << errorMessage << "\n";