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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart

Issue 101523003: Add chain support to barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 pub.load_transformers; 5 library pub.load_transformers;
6 6
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 /// The name of the type of exception thrown. 288 /// The name of the type of exception thrown.
289 /// 289 ///
290 /// This is the return value of [error.runtimeType.toString()]. Keep in mind 290 /// This is the return value of [error.runtimeType.toString()]. Keep in mind
291 /// that objects in different libraries may have the same type name. 291 /// that objects in different libraries may have the same type name.
292 final String type; 292 final String type;
293 293
294 /// The exception's message, or its [toString] if it didn't expose a `message` 294 /// The exception's message, or its [toString] if it didn't expose a `message`
295 /// property. 295 /// property.
296 final String message; 296 final String message;
297 297
298 /// The exception's stack trace, or `null` if no stack trace was available. 298 /// The exception's stack chain, or `null` if no stack chain was available.
299 final Trace stackTrace; 299 final Chain stackTrace;
300 300
301 /// Loads a [CrossIsolateException] from a map. 301 /// Loads a [CrossIsolateException] from a serialized representation.
302 /// 302 ///
303 /// [error] should be the result of [CrossIsolateException.serialize]. 303 /// [error] should be the result of [CrossIsolateException.serialize].
304 CrossIsolateException.deserialize(Map error) 304 factory CrossIsolateException.deserialize(Map error) {
305 : type = error['type'], 305 var type = error['type'];
306 message = error['message'], 306 var message = error['message'];
307 stackTrace = error['stack'] == null ? null : 307 var stackTrace = error['stack'] == null ? null :
308 new Trace.parse(error['stack']); 308 new Chain.parse(error['stack']);
309 return new CrossIsolateException._(type, message, stackTrace);
310 }
309 311
310 /// Serializes [error] to a map that can safely be passed across isolate 312 /// Loads a [CrossIsolateException] from a serialized representation.
313 ///
314 /// [error] should be the result of [CrossIsolateException.serialize].
Bob Nystrom 2013/12/04 17:37:21 Update the doc comment.
nweiz 2013/12/04 22:41:30 I've just gone back to not using a factory constru
315 CrossIsolateException._(this.type, this.message, this.stackTrace);
316
317 /// Serializes [error] to an object that can safely be passed across isolate
311 /// boundaries. 318 /// boundaries.
312 static Map serialize(error, [StackTrace stack]) { 319 static Map serialize(error, [StackTrace stack]) {
313 if (stack == null && error is Error) stack = error.stackTrace; 320 if (stack == null && error is Error) stack = error.stackTrace;
314 return { 321 return {
315 'type': error.runtimeType.toString(), 322 'type': error.runtimeType.toString(),
316 'message': getErrorMessage(error), 323 'message': getErrorMessage(error),
317 'stack': stack == null ? null : stack.toString() 324 'stack': stack == null ? null : new Chain.forTrace(stack).toString()
318 }; 325 };
319 } 326 }
320 327
321 String toString() => "\$message\\n\$stackTrace"; 328 String toString() => "\$message\\n\$stackTrace";
322 } 329 }
323 330
324 // Get a string description of an exception. 331 // Get a string description of an exception.
325 // 332 //
326 // Most exception types have a "message" property. We prefer this since 333 // Most exception types have a "message" property. We prefer this since
327 // it skips the "Exception:", "HttpException:", etc. prefix that calling 334 // it skips the "Exception:", "HttpException:", etc. prefix that calling
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 'replyTo': receivePort.sendPort 572 'replyTo': receivePort.sendPort
566 }); 573 });
567 574
568 return receivePort.first.then((response) { 575 return receivePort.first.then((response) {
569 if (response['type'] == 'success') return response['value']; 576 if (response['type'] == 'success') return response['value'];
570 assert(response['type'] == 'error'); 577 assert(response['type'] == 'error');
571 return new Future.error( 578 return new Future.error(
572 new dart.CrossIsolateException.deserialize(response['error'])); 579 new dart.CrossIsolateException.deserialize(response['error']));
573 }); 580 });
574 } 581 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698