Index: runtime/vm/dart_api_impl.cc |
=================================================================== |
--- runtime/vm/dart_api_impl.cc (revision 38636) |
+++ runtime/vm/dart_api_impl.cc (working copy) |
@@ -4793,7 +4793,7 @@ |
*result = Api::NewHandle(isolate, lib.raw()); |
} else { |
*result = Api::NewHandle(isolate, error.raw()); |
- lib.SetLoadError(); |
+ lib.SetLoadError(error); |
} |
} |
@@ -5028,6 +5028,34 @@ |
} |
+DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library_in, |
+ Dart_Handle error_in) { |
+ Isolate* isolate = Isolate::Current(); |
+ DARTSCOPE(isolate); |
+ |
+ const Library& lib = Api::UnwrapLibraryHandle(isolate, library_in); |
+ if (lib.IsNull()) { |
+ RETURN_TYPE_ERROR(isolate, library_in, Library); |
+ } |
+ const Object& err = Api::UnwrapInstanceHandle(isolate, error_in); |
+ if (err.IsNull()) { |
+ RETURN_TYPE_ERROR(isolate, error_in, Object); |
+ } |
+ CHECK_CALLBACK_STATE(isolate); |
+ |
+ const GrowableObjectArray& pending_deferred_loads = |
+ GrowableObjectArray::Handle( |
+ isolate->object_store()->pending_deferred_loads()); |
+ for (intptr_t i = 0; i < pending_deferred_loads.Length(); i++) { |
+ if (pending_deferred_loads.At(i) == lib.raw()) { |
+ lib.SetLoadError(err); |
+ return Api::Null(); |
+ } |
+ } |
+ return error_in; |
+} |
+ |
+ |
DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, |
Dart_Handle source) { |
Isolate* isolate = Isolate::Current(); |
@@ -5051,7 +5079,7 @@ |
library.Register(); |
} else if (library.LoadInProgress() || |
library.Loaded() || |
- library.LoadError()) { |
+ library.LoadFailed()) { |
// The source for this library has either been loaded or is in the |
// process of loading. Return an error. |
return Api::NewError("%s: library '%s' has already been loaded.", |