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

Unified Diff: sdk/lib/_internal/pub/lib/src/utils.dart

Issue 354053002: Report all transformer load errors before exiting. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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: sdk/lib/_internal/pub/lib/src/utils.dart
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart
index 24c9ecfc76ed0d6f42d327540f52cd139e2ab65e..d3d2c4aab2fdf6435229d1dd9bc34856348070a8 100644
--- a/sdk/lib/_internal/pub/lib/src/utils.dart
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart
@@ -16,6 +16,7 @@ import 'package:path/path.dart' as path;
import "package:stack_trace/stack_trace.dart";
import 'exceptions.dart';
+import 'log.dart' as log;
export '../../asset/dart/utils.dart';
@@ -124,6 +125,21 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) {
return completer.future;
}
+/// Like [Future.wait], but prints all errors from the futures as they occur and
+/// only returns once all Futures have completed, successfully or not.
+///
+/// This will wrap the first error thrown in a [SilentException] and rethrow it.
+Future waitAndPrintErrors(Iterable<Future> futures) {
+ return Future.wait(futures.map((future) {
+ return future.catchError((error, stackTrace) {
+ log.exception(error, stackTrace);
+ throw error;
+ });
+ })).catchError((error, stackTrace) {
+ throw new SilentException(error, stackTrace);
+ });
+}
+
/// Returns a [StreamTransformer] that will call [onDone] when the stream
/// completes.
///

Powered by Google App Engine
This is Rietveld 408576698