diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index f7d3d4c81c..24de9180ed 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -7,6 +7,7 @@ #include "flutter/fml/message_loop.h" #include "flutter/lib/ui/window/window.h" #include "lib/tonic/converter/dart_converter.h" +#include "lib/tonic/dart_message_handler.h" using tonic::ToDart; @@ -106,4 +107,12 @@ IsolateNameServer* UIDartState::GetIsolateNameServer() { return isolate_name_server_; } +tonic::DartErrorHandleType UIDartState::GetLastError() { + tonic::DartErrorHandleType error = message_handler().isolate_last_error(); + if (error == tonic::kNoError) { + error = microtask_queue_.GetLastError(); + } + return error; +} + } // namespace blink diff --git a/engine/src/flutter/lib/ui/ui_dart_state.h b/engine/src/flutter/lib/ui/ui_dart_state.h index 5cfdf9a44f..88b56b2cf0 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.h +++ b/engine/src/flutter/lib/ui/ui_dart_state.h @@ -49,6 +49,8 @@ class UIDartState : public tonic::DartState { IsolateNameServer* GetIsolateNameServer(); + tonic::DartErrorHandleType GetLastError(); + template static flow::SkiaGPUObject CreateGPUObject(sk_sp object) { if (!object) { diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index 5ef6e5a0a0..d4c191b4a5 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -270,8 +270,7 @@ bool RuntimeController::HasLivePorts() { } tonic::DartErrorHandleType RuntimeController::GetLastError() { - return root_isolate_ ? root_isolate_->message_handler().isolate_last_error() - : tonic::kNoError; + return root_isolate_ ? root_isolate_->GetLastError() : tonic::kNoError; } fml::WeakPtr RuntimeController::GetRootIsolate() {