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

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

Issue 22961002: Add more metadata to non-programmatic barback exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Small fix 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
« no previous file with comments | « pkg/barback/lib/src/asset_node.dart ('k') | pkg/barback/lib/src/errors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.build_result; 5 library barback.build_result;
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 'utils.dart'; 11 import 'utils.dart';
12 12
13 /// An event indicating that the cascade has finished building all assets. 13 /// An event indicating that the cascade has finished building all assets.
14 /// 14 ///
15 /// A build can end either in success or failure. If there were no errors during 15 /// A build can end either in success or failure. If there were no errors during
16 /// the build, it's considered to be a success; any errors render it a failure, 16 /// the build, it's considered to be a success; any errors render it a failure,
17 /// although individual assets may still have built successfully. 17 /// although individual assets may still have built successfully.
18 class BuildResult { 18 class BuildResult {
19 /// All errors that occurred during the build. 19 /// All errors that occurred during the build.
20 final List errors; 20 final Set<BarbackException> errors;
21 21
22 /// `true` if the build succeeded. 22 /// `true` if the build succeeded.
23 bool get succeeded => errors.isEmpty; 23 bool get succeeded => errors.isEmpty;
24 24
25 BuildResult(Iterable errors) 25 BuildResult(Iterable<BarbackException> errors)
26 : errors = errors.toList(); 26 : errors = errors.toSet();
27 27
28 /// Creates a build result indicating a successful build. 28 /// Creates a build result indicating a successful build.
29 /// 29 ///
30 /// This equivalent to a build result with no errors. 30 /// This equivalent to a build result with no errors.
31 BuildResult.success() 31 BuildResult.success()
32 : this([]); 32 : this([]);
33 33
34 String toString() { 34 String toString() {
35 if (succeeded) return "success"; 35 if (succeeded) return "success";
36 36
37 return "errors:\n" + errors.map((error) { 37 return "errors:\n" + errors.map((error) {
38 var stackTrace = getAttachedStackTrace(error); 38 var stackTrace = getAttachedStackTrace(error);
39 if (stackTrace != null) stackTrace = new Trace.from(stackTrace); 39 if (stackTrace != null) stackTrace = new Trace.from(stackTrace);
40 40
41 var msg = new StringBuffer(); 41 var msg = new StringBuffer();
42 msg.write(prefixLines(error.toString())); 42 msg.write(prefixLines(error.toString()));
43 if (stackTrace != null) { 43 if (stackTrace != null) {
44 msg.write("\n\n"); 44 msg.write("\n\n");
45 msg.write("Stack trace:\n"); 45 msg.write("Stack trace:\n");
46 msg.write(prefixLines(stackTrace.toString())); 46 msg.write(prefixLines(stackTrace.toString()));
47 } 47 }
48 return msg.toString(); 48 return msg.toString();
49 }).join("\n\n"); 49 }).join("\n\n");
50 } 50 }
51 } 51 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/asset_node.dart ('k') | pkg/barback/lib/src/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698