| 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 'dart:async'; | |
| 8 | |
| 9 import 'package:stack_trace/stack_trace.dart'; | |
| 10 | |
| 11 import 'errors.dart'; | 7 import 'errors.dart'; |
| 12 import 'utils.dart'; | 8 import 'utils.dart'; |
| 13 | 9 |
| 14 /// An event indicating that the cascade has finished building all assets. | 10 /// An event indicating that the cascade has finished building all assets. |
| 15 /// | 11 /// |
| 16 /// A build can end either in success or failure. If there were no errors during | 12 /// A build can end either in success or failure. If there were no errors during |
| 17 /// the build, it's considered to be a success; any errors render it a failure, | 13 /// the build, it's considered to be a success; any errors render it a failure, |
| 18 /// although individual assets may still have built successfully. | 14 /// although individual assets may still have built successfully. |
| 19 class BuildResult { | 15 class BuildResult { |
| 20 // TODO(rnystrom): Revise how to track error results. Errors can come from | 16 // TODO(rnystrom): Revise how to track error results. Errors can come from |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 var errors = unionAll(results.map((result) => result.errors)); | 38 var errors = unionAll(results.map((result) => result.errors)); |
| 43 return new BuildResult(errors); | 39 return new BuildResult(errors); |
| 44 } | 40 } |
| 45 | 41 |
| 46 String toString() { | 42 String toString() { |
| 47 if (succeeded) return "success"; | 43 if (succeeded) return "success"; |
| 48 | 44 |
| 49 return "errors:\n" + errors.map((error) { | 45 return "errors:\n" + errors.map((error) { |
| 50 var stackTrace = null; | 46 var stackTrace = null; |
| 51 if (error is TransformerException || error is AssetLoadException) { | 47 if (error is TransformerException || error is AssetLoadException) { |
| 52 stackTrace = new Trace.from(error.stackTrace); | 48 stackTrace = error.stackTrace.terse; |
| 53 } | 49 } |
| 54 | 50 |
| 55 var msg = new StringBuffer(); | 51 var msg = new StringBuffer(); |
| 56 msg.write(prefixLines(error.toString())); | 52 msg.write(prefixLines(error.toString())); |
| 57 if (stackTrace != null) { | 53 if (stackTrace != null) { |
| 58 msg.write("\n\n"); | 54 msg.write("\n\n"); |
| 59 msg.write("Stack trace:\n"); | 55 msg.write("Stack chain:\n"); |
| 60 msg.write(prefixLines(stackTrace.toString())); | 56 msg.write(prefixLines(stackTrace.toString())); |
| 61 } | 57 } |
| 62 return msg.toString(); | 58 return msg.toString(); |
| 63 }).join("\n\n"); | 59 }).join("\n\n"); |
| 64 } | 60 } |
| 65 } | 61 } |
| OLD | NEW |