| 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.errors; | 5 library barback.errors; |
| 6 | 6 |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:stack_trace/stack_trace.dart'; | 7 import 'package:stack_trace/stack_trace.dart'; |
| 10 | 8 |
| 11 import 'asset_id.dart'; | 9 import 'asset_id.dart'; |
| 12 import 'transformer.dart'; | 10 import 'transformer.dart'; |
| 13 import 'utils.dart'; | 11 import 'utils.dart'; |
| 14 | 12 |
| 15 /// Error thrown when an asset with [id] cannot be found. | 13 /// Error thrown when an asset with [id] cannot be found. |
| 16 class AssetNotFoundException implements Exception { | 14 class AssetNotFoundException implements Exception { |
| 17 final AssetId id; | 15 final AssetId id; |
| 18 | 16 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 InvalidOutputException(this.transform, this.id); | 106 InvalidOutputException(this.transform, this.id); |
| 109 | 107 |
| 110 String toString() => "Transform $transform emitted $id, which wasn't in the " | 108 String toString() => "Transform $transform emitted $id, which wasn't in the " |
| 111 "same package (${transform.primaryId.package})."; | 109 "same package (${transform.primaryId.package})."; |
| 112 } | 110 } |
| 113 | 111 |
| 114 /// Base class for an error that wraps another. | 112 /// Base class for an error that wraps another. |
| 115 abstract class _WrappedException implements BarbackException { | 113 abstract class _WrappedException implements BarbackException { |
| 116 /// The wrapped exception. | 114 /// The wrapped exception. |
| 117 final error; | 115 final error; |
| 118 final StackTrace stackTrace; | 116 final Chain stackTrace; |
| 119 | 117 |
| 120 _WrappedException(this.error, this.stackTrace); | 118 _WrappedException(this.error, StackTrace stackTrace) |
| 119 : this.stackTrace = stackTrace == null ? null : |
| 120 new Chain.forTrace(stackTrace); |
| 121 | 121 |
| 122 String get _message; | 122 String get _message; |
| 123 | 123 |
| 124 String toString() { | 124 String toString() { |
| 125 var result = "$_message: $error"; | 125 var result = "$_message: $error"; |
| 126 | 126 |
| 127 var stack = stackTrace; | 127 var stack = stackTrace; |
| 128 if (stack == null && error is Error) stack = error.stackTrace; | 128 if (stack == null && error is Error) stack = error.stackTrace; |
| 129 if (stack != null) { | 129 if (stack != null) { |
| 130 result = "$result\n${new Trace.from(stack).terse}"; | 130 result = "$result\n${stackTrace.terse}"; |
| 131 } | 131 } |
| 132 | 132 |
| 133 return result; | 133 return result; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 /// Error wrapping an exception thrown by a transform. | 137 /// Error wrapping an exception thrown by a transform. |
| 138 class TransformerException extends _WrappedException { | 138 class TransformerException extends _WrappedException { |
| 139 /// The transform that threw the exception. | 139 /// The transform that threw the exception. |
| 140 final TransformInfo transform; | 140 final TransformInfo transform; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 bool operator==(other) => | 176 bool operator==(other) => |
| 177 other is TransformInfo && | 177 other is TransformInfo && |
| 178 other.transformer == transformer && | 178 other.transformer == transformer && |
| 179 other.primaryId == primaryId; | 179 other.primaryId == primaryId; |
| 180 | 180 |
| 181 int get hashCode => transformer.hashCode ^ primaryId.hashCode; | 181 int get hashCode => transformer.hashCode ^ primaryId.hashCode; |
| 182 | 182 |
| 183 String toString() => "$transformer on $primaryId"; | 183 String toString() => "$transformer on $primaryId"; |
| 184 } | 184 } |
| OLD | NEW |