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

Side by Side Diff: runtime/bin/builtin.dart

Issue 1001733002: - Avoid rewrapping LoadError inside LoadError. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library builtin; 5 library builtin;
6 // NOTE: Do not import 'dart:io' in builtin. 6 // NOTE: Do not import 'dart:io' in builtin.
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 10
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 native "Builtin_AsyncLoadError"; 267 native "Builtin_AsyncLoadError";
268 268
269 void _loadScript(int tag, String uri, String libraryUri, List<int> data) { 269 void _loadScript(int tag, String uri, String libraryUri, List<int> data) {
270 // TODO: Currently a compilation error while loading the script is 270 // TODO: Currently a compilation error while loading the script is
271 // fatal for the isolate. _loadScriptCallback() does not return and 271 // fatal for the isolate. _loadScriptCallback() does not return and
272 // the _numOutstandingLoadRequests counter remains out of sync. 272 // the _numOutstandingLoadRequests counter remains out of sync.
273 _loadScriptCallback(tag, uri, libraryUri, data); 273 _loadScriptCallback(tag, uri, libraryUri, data);
274 _finishedOneLoadRequest(uri); 274 _finishedOneLoadRequest(uri);
275 } 275 }
276 276
277 void _asyncLoadError(tag, uri, libraryUri, error) { 277 void _asyncLoadError(int tag, String uri, String libraryUri, LoadError error) {
278 if (_logBuiltin) { 278 if (_logBuiltin) {
279 _print("_asyncLoadError($uri), error: $error"); 279 _print("_asyncLoadError($uri), error: $error");
280 } 280 }
281 if (tag == Dart_kImportTag) { 281 if (tag == Dart_kImportTag) {
282 // When importing a library, the libraryUri is the imported 282 // When importing a library, the libraryUri is the imported
283 // uri. 283 // uri.
284 libraryUri = uri; 284 libraryUri = uri;
285 } 285 }
286 _asyncLoadErrorCallback(uri, libraryUri, new LoadError(error.toString())); 286 _asyncLoadErrorCallback(uri, libraryUri, error);
287 _finishedOneLoadRequest(uri); 287 _finishedOneLoadRequest(uri);
288 } 288 }
289 289
290 290
291 _loadDataAsyncLoadPort(int tag, 291 _loadDataAsyncLoadPort(int tag,
292 String uri, 292 String uri,
293 String libraryUri, 293 String libraryUri,
294 Uri resourceUri) { 294 Uri resourceUri) {
295 var receivePort = new ReceivePort(); 295 var receivePort = new ReceivePort();
296 receivePort.first.then((dataOrError) { 296 receivePort.first.then((dataOrError) {
297 if (dataOrError is List<int>) { 297 if (dataOrError is List<int>) {
298 _loadScript(tag, uri, libraryUri, dataOrError); 298 _loadScript(tag, uri, libraryUri, dataOrError);
299 } else { 299 } else {
300 _asyncLoadError(tag, uri, libraryUri, dataOrError); 300 assert(dataOrError is String);
301 var error = new LoadError(dataOrError.toString());
rmacnak 2015/03/11 23:50:52 toString is redundant
Ivan Posva 2015/03/11 23:53:57 Redundant, but defensive in case you are not runni
302 _asyncLoadError(tag, uri, libraryUri, error);
301 } 303 }
302 }).catchError((e) { 304 }).catchError((e) {
303 _asyncLoadError(tag, uri, libraryUri, e.toString()); 305 // Wrap inside a LoadError unless we are already propagating a previously
306 // seen LoadError.
307 var error = (e is LoadError) ? e : new LoadError(e.toString);
308 _asyncLoadError(tag, uri, libraryUri, error);
304 }); 309 });
305 310
306 try { 311 try {
307 var msg = [receivePort.sendPort, resourceUri.toString()]; 312 var msg = [receivePort.sendPort, resourceUri.toString()];
308 _loadPort.send(msg); 313 _loadPort.send(msg);
309 _startingOneLoadRequest(uri); 314 _startingOneLoadRequest(uri);
310 } catch (e) { 315 } catch (e) {
311 if (_logBuiltin) { 316 if (_logBuiltin) {
312 _print("Exception when communicating with service isolate: $e"); 317 _print("Exception when communicating with service isolate: $e");
313 } 318 }
314 _asyncLoadError(tag, uri, libraryUri, e.toString()); 319 // Wrap inside a LoadError unless we are already propagating a previously
320 // seen LoadError.
321 var error = (e is LoadError) ? e : new LoadError(e.toString);
322 _asyncLoadError(tag, uri, libraryUri, error);
315 receivePort.close(); 323 receivePort.close();
316 } 324 }
317 } 325 }
318 326
319 // Asynchronously loads script data through a http[s] or file uri. 327 // Asynchronously loads script data through a http[s] or file uri.
320 _loadDataAsync(int tag, String uri, String libraryUri) { 328 _loadDataAsync(int tag, String uri, String libraryUri) {
321 if (tag == Dart_kScriptTag) { 329 if (tag == Dart_kScriptTag) {
322 uri = _resolveScriptUri(uri); 330 uri = _resolveScriptUri(uri);
323 } 331 }
324 332
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } else { 401 } else {
394 name = userUri.substring(index + 1); 402 name = userUri.substring(index + 1);
395 path = userUri.substring(0, index + 1); 403 path = userUri.substring(0, index + 1);
396 } 404 }
397 405
398 path = _filePathFromUri(path); 406 path = _filePathFromUri(path);
399 var filename = _platformExtensionFileName(name); 407 var filename = _platformExtensionFileName(name);
400 408
401 return [path, filename, name]; 409 return [path, filename, name];
402 } 410 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698