| OLD | NEW |
| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 /// [error] should be the result of [CrossIsolateException.serialize]. | 372 /// [error] should be the result of [CrossIsolateException.serialize]. |
| 373 CrossIsolateException.deserialize(Map error) | 373 CrossIsolateException.deserialize(Map error) |
| 374 : type = error['type'], | 374 : type = error['type'], |
| 375 message = error['message'], | 375 message = error['message'], |
| 376 stackTrace = error['stack'] == null ? null : | 376 stackTrace = error['stack'] == null ? null : |
| 377 new Trace.parse(error['stack']); | 377 new Trace.parse(error['stack']); |
| 378 | 378 |
| 379 /// Serializes [error] to a map that can safely be passed across isolate | 379 /// Serializes [error] to a map that can safely be passed across isolate |
| 380 /// boundaries. | 380 /// boundaries. |
| 381 static Map serialize(error, [StackTrace stack]) { | 381 static Map serialize(error, [StackTrace stack]) { |
| 382 if (stack == null) stack = getAttachedStackTrace(error); | 382 if (stack == null && error is Error) stack = error.stackTrace; |
| 383 return { | 383 return { |
| 384 'type': error.runtimeType.toString(), | 384 'type': error.runtimeType.toString(), |
| 385 'message': getErrorMessage(error), | 385 'message': getErrorMessage(error), |
| 386 'stack': stack == null ? null : stack.toString() | 386 'stack': stack == null ? null : stack.toString() |
| 387 }; | 387 }; |
| 388 } | 388 } |
| 389 | 389 |
| 390 String toString() => "\$message\\n\$stackTrace"; | 390 String toString() => "\$message\\n\$stackTrace"; |
| 391 } | 391 } |
| 392 | 392 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 'replyTo': receivePort.sendPort | 701 'replyTo': receivePort.sendPort |
| 702 }); | 702 }); |
| 703 | 703 |
| 704 return receivePort.first.then((response) { | 704 return receivePort.first.then((response) { |
| 705 if (response['type'] == 'success') return response['value']; | 705 if (response['type'] == 'success') return response['value']; |
| 706 assert(response['type'] == 'error'); | 706 assert(response['type'] == 'error'); |
| 707 return new Future.error( | 707 return new Future.error( |
| 708 new dart.CrossIsolateException.deserialize(response['error'])); | 708 new dart.CrossIsolateException.deserialize(response['error'])); |
| 709 }); | 709 }); |
| 710 } | 710 } |
| OLD | NEW |