Skip to content

Commit 873c007

Browse files
authored
Log exception in addition to the stack trace for unhandled exceptions. (flutter#20935)
* Log exception in addition to the stack trace for unhandled exceptions. Having exception logged can be especially useful when stack trace is blank.
1 parent 8f3f711 commit 873c007

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

third_party/tonic/logging/dart_error.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ const char kInvalidArgument[] = "Invalid argument.";
1414

1515
bool LogIfError(Dart_Handle handle) {
1616
if (Dart_IsUnhandledExceptionError(handle)) {
17+
Dart_Handle exception_handle = Dart_ErrorGetException(handle);
18+
const std::string exception =
19+
tonic::StdStringFromDart(Dart_ToString(exception_handle));
1720
Dart_Handle stack_trace_handle = Dart_ErrorGetStackTrace(handle);
1821
const std::string stack_trace =
1922
tonic::StdStringFromDart(Dart_ToString(stack_trace_handle));
20-
tonic::Log("Dart Unhandled Exception: %s", stack_trace.c_str());
23+
tonic::Log("Dart Unhandled Exception: %s, stack trace: %s",
24+
exception.c_str(), stack_trace.c_str());
2125
return true;
2226
} else if (Dart_IsError(handle)) {
2327
tonic::Log("Dart Error: %s", Dart_GetError(handle));

0 commit comments

Comments
 (0)