Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Log exception in addition to the stack trace for unhandled exceptions. #20935

Merged
merged 2 commits into from
Sep 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion third_party/tonic/logging/dart_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ const char kInvalidArgument[] = "Invalid argument.";

bool LogIfError(Dart_Handle handle) {
if (Dart_IsUnhandledExceptionError(handle)) {
Dart_Handle exception_handle = Dart_ErrorGetException(handle);
const std::string exception =
tonic::StdStringFromDart(Dart_ToString(exception_handle));
Dart_Handle stack_trace_handle = Dart_ErrorGetStackTrace(handle);
const std::string stack_trace =
tonic::StdStringFromDart(Dart_ToString(stack_trace_handle));
tonic::Log("Dart Unhandled Exception: %s", stack_trace.c_str());
tonic::Log("Dart Unhandled Exception: %s, stack trace: %s",
exception.c_str(), stack_trace.c_str());
return true;
} else if (Dart_IsError(handle)) {
tonic::Log("Dart Error: %s", Dart_GetError(handle));
Expand Down