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

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
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 38794)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -4793,7 +4793,9 @@
*result = Api::NewHandle(isolate, lib.raw());
} else {
*result = Api::NewHandle(isolate, error.raw());
- lib.SetLoadError();
+ // Compilation errors are not Dart instances, so just mark the library
+ // as having failed to load without providing an error instance.
+ lib.SetLoadError(Instance::Handle());
}
}
@@ -5028,6 +5030,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 Instance& err = Api::UnwrapInstanceHandle(isolate, error_in);
+ if (err.IsNull()) {
+ RETURN_TYPE_ERROR(isolate, error_in, Instance);
+ }
+ 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 +5081,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.",
@@ -5212,6 +5242,7 @@
const Object& res =
Object::Handle(isolate, DartEntry::InvokeFunction(function, args));
+ isolate->object_store()->clear_pending_deferred_loads();
if (res.IsError() || res.IsUnhandledException()) {
return Api::NewHandle(isolate, res.raw());
}
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698