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.build_result; | 5 library barback.build_result; |
6 | 6 |
7 import 'errors.dart'; | 7 import 'errors.dart'; |
8 import 'utils.dart'; | 8 import 'utils.dart'; |
9 | 9 |
10 /// An event indicating that the cascade has finished building all assets. | 10 /// An event indicating that the cascade has finished building all assets. |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 /// `true` if the build succeeded. | 23 /// `true` if the build succeeded. |
24 bool get succeeded => errors.isEmpty; | 24 bool get succeeded => errors.isEmpty; |
25 | 25 |
26 BuildResult(Iterable<BarbackException> errors) | 26 BuildResult(Iterable<BarbackException> errors) |
27 : errors = flattenAggregateExceptions(errors).toSet(); | 27 : errors = flattenAggregateExceptions(errors).toSet(); |
28 | 28 |
29 /// Creates a build result indicating a successful build. | 29 /// Creates a build result indicating a successful build. |
30 /// | 30 /// |
31 /// This equivalent to a build result with no errors. | 31 /// This equivalent to a build result with no errors. |
32 BuildResult.success() | 32 BuildResult.success() : this([]); |
33 : this([]); | |
34 | 33 |
35 /// Creates a single [BuildResult] that contains all of the errors of | 34 /// Creates a single [BuildResult] that contains all of the errors of |
36 /// [results]. | 35 /// [results]. |
37 factory BuildResult.aggregate(Iterable<BuildResult> results) { | 36 factory BuildResult.aggregate(Iterable<BuildResult> results) { |
38 var errors = unionAll(results.map((result) => result.errors)); | 37 var errors = unionAll(results.map((result) => result.errors)); |
39 return new BuildResult(errors); | 38 return new BuildResult(errors); |
40 } | 39 } |
41 | 40 |
42 String toString() { | 41 String toString() { |
43 if (succeeded) return "success"; | 42 if (succeeded) return "success"; |
44 | 43 |
45 return "errors:\n" + errors.map((error) { | 44 return "errors:\n" + |
46 var stackTrace = null; | 45 errors.map((error) { |
47 if (error is TransformerException) { | 46 var stackTrace = null; |
48 stackTrace = error.stackTrace.terse; | 47 if (error is TransformerException) { |
49 } else if (error is AssetLoadException) { | 48 stackTrace = error.stackTrace.terse; |
50 stackTrace = error.stackTrace.terse; | 49 } else if (error is AssetLoadException) { |
51 } | 50 stackTrace = error.stackTrace.terse; |
| 51 } |
52 | 52 |
53 var msg = new StringBuffer(); | 53 var msg = new StringBuffer(); |
54 msg.write(prefixLines(error.toString())); | 54 msg.write(prefixLines(error.toString())); |
55 if (stackTrace != null) { | 55 if (stackTrace != null) { |
56 msg.write("\n\n"); | 56 msg.write("\n\n"); |
57 msg.write("Stack chain:\n"); | 57 msg.write("Stack chain:\n"); |
58 msg.write(prefixLines(stackTrace.toString())); | 58 msg.write(prefixLines(stackTrace.toString())); |
59 } | 59 } |
60 return msg.toString(); | 60 return msg.toString(); |
61 }).join("\n\n"); | 61 }).join("\n\n"); |
62 } | 62 } |
63 } | 63 } |
OLD | NEW |