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

Unified Diff: pkg/barback/lib/src/build_result.dart

Issue 22265002: Support cross-package transforms in barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove a duplicated test. 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 side-by-side diff with in-line comments
Download patch
Index: pkg/barback/lib/src/build_result.dart
diff --git a/pkg/barback/lib/src/build_result.dart b/pkg/barback/lib/src/build_result.dart
new file mode 100644
index 0000000000000000000000000000000000000000..32ee7c7a217113e1feb31dc37619f6d37e9ddd3f
--- /dev/null
+++ b/pkg/barback/lib/src/build_result.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.build_result;
+
+import 'dart:async';
+
+import 'package:stack_trace/stack_trace.dart';
+
+import 'utils.dart';
+
+/// An event indicating that the cascade has finished building all assets.
+///
+/// A build can end either in success or failure. If there were no errors during
+/// the build, it's considered to be a success; any errors render it a failure,
+/// although individual assets may still have built successfully.
+class BuildResult {
+ /// All errors that occurred during the build.
+ final List errors;
+
+ /// `true` if the build succeeded.
+ bool get succeeded => errors.isEmpty;
+
+ BuildResult(Iterable errors)
+ : errors = errors.toList();
+
+ /// Creates a build result indicating a successful build.
+ ///
+ /// This equivalent to a build result with no errors.
+ BuildResult.success()
+ : this([]);
+
+ String toString() {
+ if (succeeded) return "success";
+
+ return "errors:\n" + errors.map((error) {
+ var stackTrace = getAttachedStackTrace(error);
+ if (stackTrace != null) stackTrace = new Trace.from(stackTrace);
+
+ var msg = new StringBuffer();
+ msg.write(prefixLines(error.toString()));
+ if (stackTrace != null) {
+ msg.write("\n\n");
+ msg.write("Stack trace:\n");
+ msg.write(prefixLines(stackTrace.toString()));
+ }
+ return msg.toString();
+ }).join("\n\n");
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698