Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 419103003: Handle load errors in deferred code (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.",

Powered by Google App Engine
This is Rietveld 408576698