| 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 /// A library for compiling Dart code and manipulating analyzer parse trees. | 5 /// A library for compiling Dart code and manipulating analyzer parse trees. |
| 6 library pub.dart; | 6 library pub.dart; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 /// The exception's message, or its [toString] if it didn't expose a `message` | 120 /// The exception's message, or its [toString] if it didn't expose a `message` |
| 121 /// property. | 121 /// property. |
| 122 final String message; | 122 final String message; |
| 123 | 123 |
| 124 /// The exception's stack trace, or `null` if no stack trace was available. | 124 /// The exception's stack trace, or `null` if no stack trace was available. |
| 125 final Trace stackTrace; | 125 final Trace stackTrace; |
| 126 | 126 |
| 127 /// Loads a [CrossIsolateException] from a serialized representation. | 127 /// Loads a [CrossIsolateException] from a serialized representation. |
| 128 /// | 128 /// |
| 129 /// [error] should be the result of [CrossIsolateException.serialize]. | 129 /// [error] should be the result of [CrossIsolateException.serialize]. |
| 130 CrossIsolateException.deserialize(Object error) | 130 factory CrossIsolateException.deserialize(Map error) { |
| 131 : type = error['type'], | 131 var type = error['type']; |
| 132 message = error['message'], | 132 var message = error['message']; |
| 133 stackTrace = error['stack'] == null ? null : | 133 var stackTrace = error['stack'] == null ? null : |
| 134 new Trace.parse(error['stack']); | 134 new Trace.parse(error['stack']); |
| 135 return new CrossIsolateException._(type, message, stackTrace); |
| 136 } |
| 137 |
| 138 /// Loads a [CrossIsolateException] from a serialized representation. |
| 139 /// |
| 140 /// [error] should be the result of [CrossIsolateException.serialize]. |
| 141 CrossIsolateException._(this.type, this.message, this.stackTrace); |
| 135 | 142 |
| 136 /// Serializes [error] to an object that can safely be passed across isolate | 143 /// Serializes [error] to an object that can safely be passed across isolate |
| 137 /// boundaries. | 144 /// boundaries. |
| 138 static Object serialize(error, [StackTrace stack]) { | 145 static Map serialize(error, [StackTrace stack]) { |
| 139 if (stack == null) stack = getAttachedStackTrace(error); | 146 if (stack == null) stack = getAttachedStackTrace(error); |
| 140 return { | 147 return { |
| 141 'type': error.runtimeType.toString(), | 148 'type': error.runtimeType.toString(), |
| 142 'message': getErrorMessage(error), | 149 'message': getErrorMessage(error), |
| 143 'stack': stack == null ? null : stack.toString() | 150 'stack': stack == null ? null : stack.toString() |
| 144 }; | 151 }; |
| 145 } | 152 } |
| 146 | 153 |
| 147 String toString() => "$message\n$stackTrace"; | 154 String toString() => "$message\n$stackTrace"; |
| 148 } | 155 } |
| OLD | NEW |