Chromium Code Reviews

Side by Side Diff: lib/src/asset/dart/serialize/exception.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'package:barback/barback.dart'; 5 import 'package:barback/barback.dart';
6 import 'package:stack_trace/stack_trace.dart'; 6 import 'package:stack_trace/stack_trace.dart';
7 7
8 import '../utils.dart'; 8 import '../utils.dart';
9 9
10 /// An exception that was originally raised in another isolate. 10 /// An exception that was originally raised in another isolate.
11 /// 11 ///
12 /// Exception objects can't cross isolate boundaries in general, so this class 12 /// Exception objects can't cross isolate boundaries in general, so this class
13 /// wraps as much information as can be consistently serialized. 13 /// wraps as much information as can be consistently serialized.
14 class CrossIsolateException implements Exception { 14 class CrossIsolateException implements Exception {
15 /// The name of the type of exception thrown. 15 /// The name of the type of exception thrown.
16 /// 16 ///
17 /// This is the return value of [error.runtimeType.toString()]. Keep in mind 17 /// This is the return value of [error.runtimeType.toString()]. Keep in mind
18 /// that objects in different libraries may have the same type name. 18 /// that objects in different libraries may have the same type name.
19 final String type; 19 final String type;
20 20
21 /// The exception's message, or its [toString] if it didn't expose a `message` 21 /// The exception's message, or its [toString] if it didn't expose a `message`
22 /// property. 22 /// property.
23 final String message; 23 String get message => _message;
24 final String _message;
24 25
25 /// The exception's stack chain, or `null` if no stack chain was available. 26 /// The exception's stack chain, or `null` if no stack chain was available.
26 final Chain stackTrace; 27 final Chain stackTrace;
27 28
28 /// Loads a [CrossIsolateException] from a serialized representation. 29 /// Loads a [CrossIsolateException] from a serialized representation.
29 /// 30 ///
30 /// [error] should be the result of [CrossIsolateException.serialize]. 31 /// [error] should be the result of [CrossIsolateException.serialize].
31 CrossIsolateException.deserialize(Map error) 32 CrossIsolateException.deserialize(Map error)
32 : type = error['type'], 33 : type = error['type'],
33 message = error['message'], 34 _message = error['message'],
34 stackTrace = error['stack'] == null ? null : 35 stackTrace = error['stack'] == null ? null :
35 new Chain.parse(error['stack']); 36 new Chain.parse(error['stack']);
36 37
37 /// Serializes [error] to an object that can safely be passed across isolate 38 /// Serializes [error] to an object that can safely be passed across isolate
38 /// boundaries. 39 /// boundaries.
39 static Map serialize(error, [StackTrace stack]) { 40 static Map serialize(error, [StackTrace stack]) {
40 if (stack == null && error is Error) stack = error.stackTrace; 41 if (stack == null && error is Error) stack = error.stackTrace;
41 return { 42 return {
42 'type': error.runtimeType.toString(), 43 'type': error.runtimeType.toString(),
43 'message': getErrorMessage(error), 44 'message': getErrorMessage(error),
(...skipping 47 matching lines...)
91 /// 92 ///
92 /// This handles [AssetNotFoundException]s specially, ensuring that their 93 /// This handles [AssetNotFoundException]s specially, ensuring that their
93 /// metadata is preserved. 94 /// metadata is preserved.
94 CrossIsolateException deserializeException(Map error) { 95 CrossIsolateException deserializeException(Map error) {
95 if (error['type'] == 'AssetNotFoundException') { 96 if (error['type'] == 'AssetNotFoundException') {
96 return new _CrossIsolateAssetNotFoundException.deserialize(error); 97 return new _CrossIsolateAssetNotFoundException.deserialize(error);
97 } else { 98 } else {
98 return new CrossIsolateException.deserialize(error); 99 return new CrossIsolateException.deserialize(error);
99 } 100 }
100 } 101 }
OLDNEW
« no previous file with comments | « lib/src/asset/dart/serialize/aggregate_transform.dart ('k') | lib/src/asset/dart/serialize/get_input_transform.dart » ('j') | no next file with comments »

Powered by Google App Engine