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 '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'; |
11 import 'utils.dart'; | 11 import 'utils.dart'; |
12 | 12 |
13 /// Error thrown when an asset with [id] cannot be found. | 13 /// Error thrown when an asset with [id] cannot be found. |
14 class AssetNotFoundException implements Exception { | 14 class AssetNotFoundException implements Exception { |
15 final AssetId id; | 15 final AssetId id; |
16 | 16 |
17 AssetNotFoundException(this.id); | 17 AssetNotFoundException(this.id); |
18 | 18 |
19 String toString() => "Could not find asset $id."; | 19 String toString() => "Could not find asset $id."; |
20 } | 20 } |
21 | 21 |
22 /// Replaces any occurrences of [AggregateException] in [errors] with the list | 22 /// Replaces any occurrences of [AggregateException] in [errors] with the list |
23 /// of errors it contains. | 23 /// of errors it contains. |
24 Iterable<BarbackException> flattenAggregateExceptions( | 24 Iterable<BarbackException> flattenAggregateExceptions( |
25 Iterable<BarbackException> errors) { | 25 Iterable<BarbackException> errors) { |
26 return errors.expand((error) { | 26 return errors.expand((error) { |
27 if (error is! AggregateException) return [error]; | 27 if (error is AggregateException) return error.errors; |
28 return error.errors; | 28 return [error]; |
29 }); | 29 }); |
30 } | 30 } |
31 | 31 |
32 /// The interface for exceptions from the barback graph or its transformers. | 32 /// The interface for exceptions from the barback graph or its transformers. |
33 /// | 33 /// |
34 /// These exceptions are never produced by programming errors in barback. | 34 /// These exceptions are never produced by programming errors in barback. |
35 abstract class BarbackException implements Exception { | 35 abstract class BarbackException implements Exception { |
36 /// Takes a collection of [BarbackExceptions] and returns a single exception | 36 /// Takes a collection of [BarbackExceptions] and returns a single exception |
37 /// that contains them all. | 37 /// that contains them all. |
38 /// | 38 /// |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 bool operator==(other) => | 184 bool operator==(other) => |
185 other is TransformInfo && | 185 other is TransformInfo && |
186 other.transformer == transformer && | 186 other.transformer == transformer && |
187 other.primaryId == primaryId; | 187 other.primaryId == primaryId; |
188 | 188 |
189 int get hashCode => transformer.hashCode ^ primaryId.hashCode; | 189 int get hashCode => transformer.hashCode ^ primaryId.hashCode; |
190 | 190 |
191 String toString() => "$transformer on $primaryId"; | 191 String toString() => "$transformer on $primaryId"; |
192 } | 192 } |
OLD | NEW |