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

Unified Diff: lib/src/runner/vm/catch_isolate_errors.dart

Issue 1685363002: Add a platform plugin infrastructure. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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 | « lib/src/runner/runner_test.dart ('k') | lib/src/runner/vm/environment.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/vm/catch_isolate_errors.dart
diff --git a/lib/src/runner/vm/catch_isolate_errors.dart b/lib/src/runner/vm/catch_isolate_errors.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c42719726243b1437b1086e3bedbc88ab0672eb5
--- /dev/null
+++ b/lib/src/runner/vm/catch_isolate_errors.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2015, 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.
+
+import 'dart:isolate';
+import 'dart:async';
+
+import 'package:stack_trace/stack_trace.dart';
+
+/// Capture any top-level errors (mostly lazy syntax errors, since other are
+/// caught below) and report them to the parent isolate.
+void catchIsolateErrors() {
+ var errorPort = new ReceivePort();
+ // Aet errors non-fatal because otherwise they'll be double-printed.
+ Isolate.current.setErrorsFatal(false);
+ Isolate.current.addErrorListener(errorPort.sendPort);
+ errorPort.listen((message) {
+ // Masquerade as an IsoalteSpawnException because that's what this would
+ // be if the error had been detected statically.
+ var error = new IsolateSpawnException(message[0]);
+ var stackTrace =
+ message[1] == null ? new Trace([]) : new Trace.parse(message[1]);
+ Zone.current.handleUncaughtError(error, stackTrace);
+ });
+}
« no previous file with comments | « lib/src/runner/runner_test.dart ('k') | lib/src/runner/vm/environment.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698