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..08924dce5eb39d9793c3c73cc24933555b2bd4d0 |
--- /dev/null |
+++ b/lib/src/runner/vm/catch_isolate_errors.dart |
@@ -0,0 +1,36 @@ |
+// 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'; |
+ |
+import '../../backend/declarer.dart'; |
kevmoo
2016/02/11 19:57:50
All of these seem to be unused imports...
nweiz
2016/02/11 21:29:18
Done.
|
+import '../../backend/group.dart'; |
+import '../../backend/live_test.dart'; |
+import '../../backend/metadata.dart'; |
+import '../../backend/suite.dart'; |
+import '../../backend/test.dart'; |
+import '../../backend/test_platform.dart'; |
+import '../../util/io.dart'; |
+import '../../util/remote_exception.dart'; |
+import '../../utils.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); |
+ }); |
+} |