| Index: runtime/bin/loader.cc
|
| diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc
|
| index f43cf30056225291aa737c67d9a5b46e6d4d8145..a23cb7fd1cb7a5251043ccb81141092444d89eb5 100644
|
| --- a/runtime/bin/loader.cc
|
| +++ b/runtime/bin/loader.cc
|
| @@ -213,17 +213,6 @@ void Loader::BlockUntilComplete() {
|
|
|
|
|
| bool Loader::ProcessResultLocked(Loader::IOResult* result) {
|
| - // A negative result tag indicates a loading error occurred in the service
|
| - // isolate. The payload is a C string of the error message.
|
| - if (result->tag < 0) {
|
| - error_ =
|
| - Dart_NewUnhandledExceptionError(
|
| - Dart_NewStringFromUTF8(result->payload,
|
| - result->payload_length));
|
| -
|
| - return false;
|
| - }
|
| -
|
| // We have to copy everything we care about out of |result| because after
|
| // dropping the lock below |result| may no longer valid.
|
| Dart_Handle uri =
|
| @@ -233,6 +222,29 @@ bool Loader::ProcessResultLocked(Loader::IOResult* result) {
|
| library_uri =
|
| Dart_NewStringFromCString(reinterpret_cast<char*>(result->library_uri));
|
| }
|
| +
|
| + // A negative result tag indicates a loading error occurred in the service
|
| + // isolate. The payload is a C string of the error message.
|
| + if (result->tag < 0) {
|
| + Dart_Handle library = Dart_LookupLibrary(uri);
|
| + Dart_Handle error = Dart_NewStringFromUTF8(result->payload,
|
| + result->payload_length);
|
| + // If a library with the given uri exists, give it a chance to handle
|
| + // the error. If the load requests stems from a deferred library load,
|
| + // an IO error is not fatal.
|
| + if (!Dart_IsNull(library) && !Dart_IsError(library)) {
|
| + ASSERT(Dart_IsLibrary(library));
|
| + Dart_Handle res = Dart_LibraryHandleError(library, error);
|
| + if (Dart_IsNull(res)) {
|
| + return true;
|
| + }
|
| + }
|
| + // Fall through
|
| + error_ = Dart_NewUnhandledExceptionError(error);
|
| + return false;
|
| + }
|
| +
|
| +
|
| // Check for payload and load accordingly.
|
| bool is_snapshot = false;
|
| const uint8_t* payload = result->payload;
|
|
|