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

Side by Side Diff: pkg/barback/lib/src/errors.dart

Issue 307543006: Add a "message" field to wrapped barback exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months 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
« no previous file with comments | « pkg/barback/CHANGELOG.md ('k') | pkg/barback/lib/src/serialize.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 barback.errors; 5 library barback.errors;
6 6
7 import 'package:stack_trace/stack_trace.dart'; 7 import 'package:stack_trace/stack_trace.dart';
8 8
9 import 'asset/asset_id.dart'; 9 import 'asset/asset_id.dart';
10 import 'transformer/wrapping_aggregate_transformer.dart'; 10 import 'transformer/wrapping_aggregate_transformer.dart';
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 String toString() => "Transform $transform emitted $id, which wasn't in the " 108 String toString() => "Transform $transform emitted $id, which wasn't in the "
109 "same package (${transform.primaryId.package})."; 109 "same package (${transform.primaryId.package}).";
110 } 110 }
111 111
112 /// Base class for an error that wraps another. 112 /// Base class for an error that wraps another.
113 abstract class _WrappedException implements BarbackException { 113 abstract class _WrappedException implements BarbackException {
114 /// The wrapped exception. 114 /// The wrapped exception.
115 final error; 115 final error;
116 final Chain stackTrace; 116 final Chain stackTrace;
117 117
118 String get message => "$_message: ${getErrorMessage(error)}";
119
120 String get _message;
121
118 _WrappedException(error, StackTrace stackTrace) 122 _WrappedException(error, StackTrace stackTrace)
119 : this.error = error, 123 : this.error = error,
120 this.stackTrace = _getChain(error, stackTrace); 124 this.stackTrace = _getChain(error, stackTrace);
121 125
122 String get _message;
123
124 String toString() { 126 String toString() {
125 var result = "$_message: $error"; 127 var result = message;
126 if (stackTrace != null) result = "$result\n${stackTrace.terse}"; 128 if (stackTrace != null) result = "$result\n${stackTrace.terse}";
127 return result; 129 return result;
128 } 130 }
129 } 131 }
130 132
131 /// Returns the stack chain for [error] and [stackTrace]. 133 /// Returns the stack chain for [error] and [stackTrace].
132 Chain _getChain(error, StackTrace stackTrace) { 134 Chain _getChain(error, StackTrace stackTrace) {
133 if (error is Error && stackTrace == null) stackTrace = error.stackTrace; 135 if (error is Error && stackTrace == null) stackTrace = error.stackTrace;
134 if (stackTrace != null) return new Chain.forTrace(stackTrace); 136 if (stackTrace != null) return new Chain.forTrace(stackTrace);
135 return null; 137 return null;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 183
182 bool operator==(other) => 184 bool operator==(other) =>
183 other is TransformInfo && 185 other is TransformInfo &&
184 other.transformer == transformer && 186 other.transformer == transformer &&
185 other.primaryId == primaryId; 187 other.primaryId == primaryId;
186 188
187 int get hashCode => transformer.hashCode ^ primaryId.hashCode; 189 int get hashCode => transformer.hashCode ^ primaryId.hashCode;
188 190
189 String toString() => "$transformer on $primaryId"; 191 String toString() => "$transformer on $primaryId";
190 } 192 }
OLDNEW
« no previous file with comments | « pkg/barback/CHANGELOG.md ('k') | pkg/barback/lib/src/serialize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698