Chromium Code Reviews| Index: runtime/bin/builtin.dart |
| diff --git a/runtime/bin/builtin.dart b/runtime/bin/builtin.dart |
| index f162bcb2c8ec44cbfc60cbcbf1dc1c54d1a9655a..6734db2d04ff26439d2bfd9eba4d7d118613f988 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,17 @@ 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()); |
| + if (e is! _LoadError) { |
| + print("Wrapped error is $e"); |
|
Ivan Posva
2016/01/29 23:33:29
Don't think this is needed.
turnidge
2016/01/30 00:29:00
Done.
|
| + } |
| + var error = |
| + (e is _LoadError) ? e : new _LoadError(req, e.toString()); |
|
Ivan Posva
2016/01/29 23:33:29
Put back on one line.
turnidge
2016/01/30 00:29:00
Done.
|
| assert(req != null); |
| _asyncLoadError(req, error, s); |
| } |
| @@ -576,11 +587,12 @@ _loadDataFromLoadPort(int tag, String uri, Uri resourceUri, context) { |
| if (_traceLoading) { |
| _log("Exception when communicating with service isolate: $e"); |
| } |
| - // 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. |
|
Ivan Posva
2016/01/29 23:33:29
// Register a dummy load request so we can fail to
turnidge
2016/01/30 00:29:00
Done.
|
| 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(req, e.toString()); |
| _asyncLoadError(req, error, s); |
| } |
| } |
| @@ -597,11 +609,12 @@ _loadPackage(int tag, String uri, Uri resourceUri, context) { |
| if (_traceLoading) { |
| _log("Exception ($e) when resolving package URI: $resourceUri"); |
| } |
| - // 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. |
|
Ivan Posva
2016/01/29 23:33:29
ditto
turnidge
2016/01/30 00:29:00
Done.
|
| 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(req, e.toString()); |
| _asyncLoadError(req, error, s); |
| } |
| _loadData(tag, uri, resolvedUri, context); |