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. |
/// |