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

Unified Diff: pkg/testing/lib/src/error_handling.dart

Issue 2624373003: Move package:testing to SDK. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/testing/lib/src/discover.dart ('k') | pkg/testing/lib/src/log.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/testing/lib/src/error_handling.dart
diff --git a/pkg/testing/lib/src/error_handling.dart b/pkg/testing/lib/src/error_handling.dart
new file mode 100644
index 0000000000000000000000000000000000000000..325afed58adc909fe92d36df6e8c4c4241245221
--- /dev/null
+++ b/pkg/testing/lib/src/error_handling.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2016, 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.md file.
+
+library testing.error_handling;
+
+import 'dart:async' show
+ Future;
+
+import 'dart:io' show
+ exitCode,
+ stderr;
+
+import 'dart:isolate' show
+ ReceivePort;
+
+Future withErrorHandling(Future f()) async {
+ final ReceivePort port = new ReceivePort();
+ try {
+ return await f();
+ } catch (e, trace) {
+ exitCode = 1;
+ stderr.writeln(e);
+ if (trace != null) {
+ stderr.writeln(trace);
+ }
+ } finally {
+ port.close();
+ }
+}
« no previous file with comments | « pkg/testing/lib/src/discover.dart ('k') | pkg/testing/lib/src/log.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698