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

Side by Side Diff: sdk/lib/isolate/base.dart

Issue 12886011: Add unhandledExceptionCallback to streamSpawnFunction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.isolate; 5 part of dart.isolate;
6 6
7 class IsolateSpawnException implements Exception { 7 class IsolateSpawnException implements Exception {
8 const IsolateSpawnException(String this._s); 8 const IsolateSpawnException(String this._s);
9 String toString() => "IsolateSpawnException: '$_s'"; 9 String toString() => "IsolateSpawnException: '$_s'";
10 final String _s; 10 final String _s;
(...skipping 13 matching lines...) Expand all
24 * argument must be a static top-level function or a static method that takes no 24 * argument must be a static top-level function or a static method that takes no
25 * arguments. It is illegal to pass a function closure. 25 * arguments. It is illegal to pass a function closure.
26 * 26 *
27 * When any isolate starts (even the main script of the application), a default 27 * When any isolate starts (even the main script of the application), a default
28 * [ReceivePort] is created for it. This port is available from the top-level 28 * [ReceivePort] is created for it. This port is available from the top-level
29 * getter [port] defined in this library. 29 * getter [port] defined in this library.
30 * 30 *
31 * [spawnFunction] returns a [SendPort] derived from the child isolate's default 31 * [spawnFunction] returns a [SendPort] derived from the child isolate's default
32 * port. 32 * port.
33 * 33 *
34 * See comments at the top of this library for more details. 34 * See comments at the top of this library for more details.
Søren Gjesse 2013/03/18 14:35:03 Maybe add some documentation on the unhandledExcep
floitsch 2013/03/18 19:07:10 Done.
35 */ 35 */
36 SendPort spawnFunction(void topLevelFunction(), 36 SendPort spawnFunction(void topLevelFunction(),
37 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]) 37 [bool unhandledExceptionCallback(IsolateUnhandledException e)])
38 => _Isolate.spawnFunction(topLevelFunction, UnhandledExceptionCallback); 38 => _Isolate.spawnFunction(topLevelFunction, unhandledExceptionCallback);
39 39
40 /** 40 /**
41 * Creates and spawns an isolate whose code is available at [uri]. Like with 41 * Creates and spawns an isolate whose code is available at [uri]. Like with
42 * [spawnFunction], the child isolate will have a default [ReceivePort], and a 42 * [spawnFunction], the child isolate will have a default [ReceivePort], and a
43 * this function returns a [SendPort] derived from it. 43 * this function returns a [SendPort] derived from it.
44 * 44 *
45 * See comments at the top of this library for more details. 45 * See comments at the top of this library for more details.
46 */ 46 */
47 SendPort spawnUri(String uri) => _Isolate.spawnUri(uri); 47 SendPort spawnUri(String uri) => _Isolate.spawnUri(uri);
48 48
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 */ 164 */
165 int get hashCode; 165 int get hashCode;
166 } 166 }
167 167
168 // The VM doesn't support accessing external globals in the same library. We 168 // The VM doesn't support accessing external globals in the same library. We
169 // therefore create this wrapper class. 169 // therefore create this wrapper class.
170 // TODO(6997): Don't go through static class for external variables. 170 // TODO(6997): Don't go through static class for external variables.
171 abstract class _Isolate { 171 abstract class _Isolate {
172 external static ReceivePort get port; 172 external static ReceivePort get port;
173 external static SendPort spawnFunction(void topLevelFunction(), 173 external static SendPort spawnFunction(void topLevelFunction(),
174 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]); 174 [bool unhandledExceptionCallback(IsolateUnhandledException e)]);
175 external static SendPort spawnUri(String uri); 175 external static SendPort spawnUri(String uri);
176 } 176 }
177 177
178 /** 178 /**
179 * Wraps unhandled exceptions thrown during isolate execution. It is 179 * Wraps unhandled exceptions thrown during isolate execution. It is
180 * used to show both the error message and the stack trace for unhandled 180 * used to show both the error message and the stack trace for unhandled
181 * exceptions. 181 * exceptions.
182 */ 182 */
183 class IsolateUnhandledException implements Exception { 183 class IsolateUnhandledException implements Exception {
184 /** Message being handled when exception occurred. */ 184 /** Message being handled when exception occurred. */
185 final message; 185 final message;
186 186
187 /** Wrapped exception. */ 187 /** Wrapped exception. */
188 final source; 188 final source;
189 189
190 /** Trace for the wrapped exception. */ 190 /** Trace for the wrapped exception. */
191 final Object stackTrace; 191 final Object stackTrace;
192 192
193 const IsolateUnhandledException(this.message, this.source, this.stackTrace); 193 const IsolateUnhandledException(this.message, this.source, this.stackTrace);
194 194
195 String toString() { 195 String toString() {
196 return 'IsolateUnhandledException: exception while handling message: ' 196 return 'IsolateUnhandledException: exception while handling message: '
197 '${message} \n ' 197 '${message} \n '
198 '${source.toString().replaceAll("\n", "\n ")}\n' 198 '${source.toString().replaceAll("\n", "\n ")}\n'
199 'original stack trace:\n ' 199 'original stack trace:\n '
200 '${stackTrace.toString().replaceAll("\n","\n ")}'; 200 '${stackTrace.toString().replaceAll("\n","\n ")}';
201 } 201 }
202 } 202 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/isolate_patch.dart ('k') | sdk/lib/isolate/isolate_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698