[Lldb-commits] [lldb] [lldb/Interpreter] Surface Python exceptions from scripted extensions (PR #198153)
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 27 17:07:21 PDT 2026
================
@@ -62,18 +62,20 @@ class ScriptedInterface {
static Ret ErrorWithMessage(llvm::StringRef caller_name,
llvm::StringRef error_msg, Status &error,
LLDBLog log_category = LLDBLog::Process) {
+ // Log the error for debugging (includes function signature for context).
LLDB_LOGF(GetLog(log_category), "%s ERROR = %s", caller_name.data(),
error_msg.data());
- std::string full_error_message =
- llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
- llvm::Twine(error_msg))
- .str();
- if (const char *detailed_error = error.AsCString())
- full_error_message +=
- llvm::Twine(llvm::Twine(" (") + llvm::Twine(detailed_error) +
- llvm::Twine(")"))
- .str();
- error = Status(std::move(full_error_message));
+
+ // For user-facing messages, just pass through the Status if it already
+ // has detailed information (like Python tracebacks); otherwise set it.
+ llvm::StringRef existing_error = error.AsCString();
+ if (!error.Fail() || existing_error.empty()) {
+ // Status is empty, populate it with the simple error message.
+ error = Status::FromErrorString(error_msg.data());
+ }
+ // If Status already has content, leave it as-is (it has the Python
+ // traceback).
+
----------------
medismailben wrote:
Good call
https://github.com/llvm/llvm-project/pull/198153
More information about the lldb-commits
mailing list