| Index: runtime/vm/dart_api_impl.cc
|
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
|
| index 89a22ce2977bad734f1d1fa0d2aa88f3e2f0d4e7..405954d314094a7918ab4c1952f43b1b02a8f10a 100644
|
| --- a/runtime/vm/dart_api_impl.cc
|
| +++ b/runtime/vm/dart_api_impl.cc
|
| @@ -814,9 +814,14 @@ DART_EXPORT Dart_Handle Dart_NewUnhandledExceptionError(Dart_Handle exception) {
|
| DARTSCOPE(isolate);
|
| CHECK_CALLBACK_STATE(isolate);
|
|
|
| - const Instance& obj = Api::UnwrapInstanceHandle(isolate, exception);
|
| - if (obj.IsNull()) {
|
| - RETURN_TYPE_ERROR(isolate, exception, Instance);
|
| + Instance& obj = Instance::Handle(isolate);
|
| + if (Dart_IsApiError(exception) || Dart_IsCompilationError(exception)) {
|
| + obj = String::New(Dart_GetError(exception));
|
| + } else {
|
| + obj = Api::UnwrapInstanceHandle(isolate, exception).raw();
|
| + if (obj.IsNull()) {
|
| + RETURN_TYPE_ERROR(isolate, exception, Instance);
|
| + }
|
| }
|
| const Stacktrace& stacktrace = Stacktrace::Handle(isolate);
|
| return Api::NewHandle(isolate, UnhandledException::New(obj, stacktrace));
|
|
|