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

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

Issue 22824023: Start sketching out a buildAll() method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't wrap a single error in an aggregate. Created 7 years, 4 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
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 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
11 import 'asset_id.dart'; 11 import 'asset_id.dart';
12 import 'transformer.dart'; 12 import 'transformer.dart';
13 13
14 /// Error thrown when an asset with [id] cannot be found. 14 /// Error thrown when an asset with [id] cannot be found.
15 class AssetNotFoundException implements Exception { 15 class AssetNotFoundException implements Exception {
16 final AssetId id; 16 final AssetId id;
17 17
18 AssetNotFoundException(this.id); 18 AssetNotFoundException(this.id);
19 19
20 String toString() => "Could not find asset $id."; 20 String toString() => "Could not find asset $id.";
21 } 21 }
22 22
23 /// Recursively removes any occurrences of [AggregateException] in [errors]
nweiz 2013/08/20 19:59:26 "removes" -> "replaces" Doing this recursively se
Bob Nystrom 2013/08/20 21:29:20 Done.
24 /// with the list of errors it contains.
25 Iterable<BarbackException> flattenAggregateExceptions(
26 Iterable<BarbackException> errors) {
27 return errors.expand((error) {
28 if (error is! AggregateException) return [error];
29 return flattenAggregateExceptions(error.errors);
30 });
31 }
32
23 /// The interface for exceptions from the barback graph or its transformers. 33 /// The interface for exceptions from the barback graph or its transformers.
24 /// 34 ///
25 /// These exceptions are never produced by programming errors in barback. 35 /// These exceptions are never produced by programming errors in barback.
26 abstract class BarbackException implements Exception {} 36 abstract class BarbackException implements Exception {}
27 37
38 /// An error that wraps a collection of other [BarbackException]s.
39 ///
40 /// It implicitly flattens any [AggregateException]s that occur in the list
nweiz 2013/08/20 19:59:26 "list exceptions" -> "list of exceptions"
Bob Nystrom 2013/08/20 21:29:20 Done.
41 /// exceptions it wraps.
42 class AggregateException implements BarbackException {
43 final List<BarbackException> errors;
nweiz 2013/08/20 19:59:26 It seems like this should be a set, since the orde
Bob Nystrom 2013/08/20 21:29:20 Done.
44
45 AggregateException(Iterable<BarbackException> errors)
46 : errors = flattenAggregateExceptions(errors).toList();
47 }
nweiz 2013/08/20 19:59:26 It would be nice to have a static method here that
Bob Nystrom 2013/08/20 21:29:20 Done.
48
28 /// Error thrown when two or more transformers both output an asset with [id]. 49 /// Error thrown when two or more transformers both output an asset with [id].
29 class AssetCollisionException implements BarbackException { 50 class AssetCollisionException implements BarbackException {
30 /// All the transforms that output an asset with [id]. 51 /// All the transforms that output an asset with [id].
31 /// 52 ///
32 /// If this only contains a single transform, that indicates that a 53 /// If this only contains a single transform, that indicates that a
33 /// transformer produced an output that collides with a source asset or an 54 /// transformer produced an output that collides with a source asset or an
34 /// asset from a previous phase. 55 /// asset from a previous phase.
35 final Set<TransformInfo> transforms; 56 final Set<TransformInfo> transforms;
36 final AssetId id; 57 final AssetId id;
37 58
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 134
114 bool operator==(other) => 135 bool operator==(other) =>
115 other is TransformInfo && 136 other is TransformInfo &&
116 other.transformer == transformer && 137 other.transformer == transformer &&
117 other.primaryId == primaryId; 138 other.primaryId == primaryId;
118 139
119 int get hashCode => transformer.hashCode ^ primaryId.hashCode; 140 int get hashCode => transformer.hashCode ^ primaryId.hashCode;
120 141
121 String toString() => "$transformer on $primaryId"; 142 String toString() => "$transformer on $primaryId";
122 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698