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

Unified Diff: sdk/lib/isolate/base.dart

Issue 11558034: Second version of support for specifying an unhandled exception callback (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/isolate/base.dart
===================================================================
--- sdk/lib/isolate/base.dart (revision 16084)
+++ sdk/lib/isolate/base.dart (working copy)
@@ -32,8 +32,8 @@
* See comments at the top of this library for more details.
*/
// Note this feature is not yet available in the dartvm.
-external SendPort spawnFunction(void topLevelFunction());
-
+external SendPort spawnFunction(void topLevelFunction(),
+ [bool UnhandledExceptionCallback(IsolateUnhandledException e)]);
/**
* Creates and spawns an isolate whose code is available at [uri]. Like with
* [spawnFunction], the child isolate will have a default [ReceivePort], and a
@@ -142,3 +142,29 @@
callSync(var message);
}
+
+/**
+ * Wraps unhandled exceptions thrown during isolate execution. It is
+ * used to show both the error message and the stack trace for unhandled
+ * exceptions.
+ */
+class IsolateUnhandledException implements Exception {
+ /** Message being handled when exception occurred. */
+ final message;
+
+ /** Wrapped exception. */
+ final source;
+
+ /** Trace for the wrapped exception. */
+ final Object stackTrace;
+
+ const IsolateUnhandledException(this.message, this.source, this.stackTrace);
+
+ String toString() {
+ return 'IsolateUnhandledException: exception while handling message: '
+ '${message} \n '
+ '${source.toString().replaceAll("\n", "\n ")}\n'
+ 'original stack trace:\n '
+ '${stackTrace.toString().replaceAll("\n","\n ")}';
+ }
+}
« runtime/vm/isolate.cc ('K') | « sdk/lib/_internal/compiler/implementation/lib/isolate_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698