| 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 barback.serialize; | 5 library barback.serialize; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
| 9 | 9 |
| 10 import 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| 11 | 11 |
| 12 import 'asset_id.dart'; | 12 import 'asset/asset_id.dart'; |
| 13 import 'utils.dart'; | 13 import 'utils.dart'; |
| 14 | 14 |
| 15 /// Converts [id] into a serializable map. | 15 /// Converts [id] into a serializable map. |
| 16 Map serializeId(AssetId id) => {'package': id.package, 'path': id.path}; | 16 Map serializeId(AssetId id) => {'package': id.package, 'path': id.path}; |
| 17 | 17 |
| 18 /// Converts [stream] into a [SendPort] with which another isolate can request | 18 /// Converts [stream] into a [SendPort] with which another isolate can request |
| 19 /// the data from [stream]. | 19 /// the data from [stream]. |
| 20 SendPort serializeStream(Stream stream) { | 20 SendPort serializeStream(Stream stream) { |
| 21 var receivePort = new ReceivePort(); | 21 var receivePort = new ReceivePort(); |
| 22 receivePort.first.then((sendPort) { | 22 receivePort.first.then((sendPort) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 /// A regular expression to match the exception prefix that some exceptions' | 115 /// A regular expression to match the exception prefix that some exceptions' |
| 116 /// [Object.toString] values contain. | 116 /// [Object.toString] values contain. |
| 117 final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): '); | 117 final _exceptionPrefix = new RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): '); |
| 118 | 118 |
| 119 /// Get a string description of an exception. | 119 /// Get a string description of an exception. |
| 120 /// | 120 /// |
| 121 /// Many exceptions include the exception class name at the beginning of their | 121 /// Many exceptions include the exception class name at the beginning of their |
| 122 /// [toString], so we remove that if it exists. | 122 /// [toString], so we remove that if it exists. |
| 123 String _getErrorMessage(error) => | 123 String _getErrorMessage(error) => |
| 124 error.toString().replaceFirst(_exceptionPrefix, ''); | 124 error.toString().replaceFirst(_exceptionPrefix, ''); |
| OLD | NEW |