[lldb] Improve error reporting in ScriptedInterface
authorMed Ismail Bennani <medismail.bennani@gmail.com>
Fri, 17 Feb 2023 01:34:37 +0000 (17:34 -0800)
committerMed Ismail Bennani <medismail.bennani@gmail.com>
Sat, 4 Mar 2023 03:33:02 +0000 (19:33 -0800)
This patch improve error reporting in the Scripted Interface.

Previously, it would only log the content of the Status object and
overwrite it with the error_msg function parameter.

This patch changes that to append the Status object content to the
`error_msg` string.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
lldb/include/lldb/Interpreter/ScriptedInterface.h

index 31064de..10a9f41 100644 (file)
@@ -40,9 +40,12 @@ public:
                               LLDBLog log_caterogy = LLDBLog::Process) {
     LLDB_LOGF(GetLog(log_caterogy), "%s ERROR = %s", caller_name.data(),
               error_msg.data());
-    error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
-                                     llvm::Twine(error_msg))
-                             .str());
+    llvm::Twine err = llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
+                                  llvm::Twine(error_msg));
+    if (const char *detailed_error = error.AsCString())
+      err.concat(llvm::Twine(" (") + llvm::Twine(detailed_error) +
+                 llvm::Twine(")"));
+    error.SetErrorString(err.str());
     return {};
   }