Index: sdk/lib/isolate/base.dart |
diff --git a/sdk/lib/isolate/base.dart b/sdk/lib/isolate/base.dart |
index e43e3bbe9b0986ed4c208b6045c07cf861b58c73..1c3b43712dc074f336069f710559e58f8eff527e 100644 |
--- a/sdk/lib/isolate/base.dart |
+++ b/sdk/lib/isolate/base.dart |
@@ -32,8 +32,8 @@ external ReceivePort get port; |
* 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 |
@@ -41,7 +41,8 @@ external SendPort spawnFunction(void topLevelFunction()); |
* |
* See comments at the top of this library for more details. |
*/ |
-external SendPort spawnUri(String uri); |
+external SendPort spawnUri(String uri, |
+ [bool UnhandledExceptionCallback(IsolateUnhandledException e)]); |
/** |
* [SendPort]s are created from [ReceivePort]s. Any message sent through |
@@ -142,3 +143,34 @@ abstract class SendPortSync { |
callSync(var message); |
} |
+ |
+class _ReceivePortFactory { |
+ external factory ReceivePort(); |
+} |
siva
2012/11/21 00:45:04
What is this change? Is it related to the Unhandle
Tom Ball
2012/11/21 05:22:38
I didn't write this, so I'm guessing it's related
|
+ |
+/** |
+ * 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 ")}'; |
+ } |
+} |
+ |