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

Unified Diff: runtime/bin/builtin.dart

Issue 1641383003: Improve the error message when an import fails. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code review Created 4 years, 11 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 | « no previous file | runtime/bin/vmservice/loader.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/builtin.dart
diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart
index f162bcb2c8ec44cbfc60cbcbf1dc1c54d1a9655a..9a34b51cb0b4c31a7ae682b7637966357b81c124 100644
--- a/runtime/bin/builtin.dart
+++ b/runtime/bin/builtin.dart
@@ -123,11 +123,18 @@ _log(msg) {
// A class wrapping the load error message in an Error object.
class _LoadError extends Error {
+ final _LoadRequest request;
final String message;
- final String uri;
- _LoadError(this.uri, this.message);
+ _LoadError(this.request, this.message);
- String toString() => 'Load Error for "$uri": $message';
+ String toString() {
+ var context = request._context;
+ if (context == null || context is! String) {
+ return 'Could not load "${request._uri}": $message';
+ } else {
+ return 'Could not import "${request._uri}" from "$context": $message';
+ }
+ }
}
// Class collecting all of the information about a particular load request.
@@ -372,13 +379,13 @@ void _handleLoaderReply(msg) {
_finishLoadRequest(req);
} else {
assert(dataOrError is String);
- var error = new _LoadError(req._uri, dataOrError.toString());
+ var error = new _LoadError(req, dataOrError.toString());
_asyncLoadError(req, error, null);
}
} catch(e, s) {
// Wrap inside a _LoadError unless we are already propagating a
// previous _LoadError.
- var error = (e is _LoadError) ? e : new _LoadError(req._uri, e.toString());
+ var error = (e is _LoadError) ? e : new _LoadError(req, e.toString());
assert(req != null);
_asyncLoadError(req, error, s);
}
@@ -576,11 +583,12 @@ _loadDataFromLoadPort(int tag, String uri, Uri resourceUri, context) {
if (_traceLoading) {
_log("Exception when communicating with service isolate: $e");
}
+ // Register a dummy load request so we can fail to load it.
+ var req = new _LoadRequest(tag, uri, resourceUri, context);
+
// Wrap inside a _LoadError unless we are already propagating a previously
// seen _LoadError.
- var error = (e is _LoadError) ? e : new _LoadError(uri, e.toString());
- // Register a dummy load request and fail to load it.
- var req = new _LoadRequest(tag, uri, resourceUri, context);
+ var error = (e is _LoadError) ? e : new _LoadError(req, e.toString());
_asyncLoadError(req, error, s);
}
}
@@ -597,11 +605,12 @@ _loadPackage(int tag, String uri, Uri resourceUri, context) {
if (_traceLoading) {
_log("Exception ($e) when resolving package URI: $resourceUri");
}
+ // Register a dummy load request so we can fail to load it.
+ var req = new _LoadRequest(tag, uri, resourceUri, context);
+
// Wrap inside a _LoadError unless we are already propagating a previously
// seen _LoadError.
- var error = (e is _LoadError) ? e : new _LoadError(uri, e.toString());
- // Register a dummy load request and fail to load it.
- var req = new _LoadRequest(tag, uri, resourceUri, context);
+ var error = (e is _LoadError) ? e : new _LoadError(req, e.toString());
_asyncLoadError(req, error, s);
}
_loadData(tag, uri, resolvedUri, context);
« no previous file with comments | « no previous file | runtime/bin/vmservice/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698