Index: runtime/bin/loader.cc |
diff --git a/runtime/bin/loader.cc b/runtime/bin/loader.cc |
index f43cf30056225291aa737c67d9a5b46e6d4d8145..c4e472b1cd7a2147e5075452497fd6da3d6e89e6 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 ((library != Dart_Null()) && !Dart_IsError(library)) { |
hausner
2016/06/07 21:47:05
Is there a difference between x != Dart_Null() and
Cutch
2016/06/07 22:29:26
No difference, but I switched to Dart_IsNull().
|
+ 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; |