diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp index 1d171c6b6c374..5757935fb8622 100644 --- a/lldb/source/Utility/Status.cpp +++ b/lldb/source/Utility/Status.cpp @@ -258,7 +258,11 @@ ErrorType Status::GetType() const { // Return the first only. if (result != eErrorTypeInvalid) return; - result = ErrorCodeToErrorType(error.convertToErrorCode()); + if (error.isA()) + result = static_cast(error).GetErrorType(); + else + result = ErrorCodeToErrorType(error.convertToErrorCode()); + }); return result; } diff --git a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py index fac562edf9ece..b9b5bffb87e81 100644 --- a/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py +++ b/lldb/test/API/commands/expression/diagnostics/TestExprDiagnostics.py @@ -184,6 +184,18 @@ def test_source_locations_from_objc_modules(self): # the first argument are probably stable enough that this test can check for them. self.assertIn("void NSLog(NSString *format", value.GetError().GetCString()) + def test_error_type(self): + """Test the error reporting in the API""" + self.build() + + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( + self, "// Break here", self.main_source_spec + ) + frame = thread.GetFrameAtIndex(0) + value = frame.EvaluateExpression('#error("I am error.")') + error = value.GetError() + self.assertEqual(error.GetType(), lldb.eErrorTypeExpression) + def test_command_expr_sbdata(self): """Test the structured diagnostics data""" self.build()