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

Side by Side Diff: sdk/lib/async/async_error.dart

Issue 48483002: Remove deprecated parts of dart:async. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 7 years, 1 month 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.async; 5 part of dart.async;
6 6
7 final Expando _stackTraceExpando = new Expando("asynchronous error");
8
9 void _attachStackTrace(o, StackTrace st) {
10 if (o == null || o is bool || o is num || o is String) return;
11 _stackTraceExpando[o] = st;
12 }
13
14 _invokeErrorHandler(Function errorHandler, 7 _invokeErrorHandler(Function errorHandler,
15 Object error, StackTrace stackTrace) { 8 Object error, StackTrace stackTrace) {
16 if (errorHandler is ZoneBinaryCallback) { 9 if (errorHandler is ZoneBinaryCallback) {
17 return errorHandler(error, stackTrace); 10 return errorHandler(error, stackTrace);
18 } else { 11 } else {
19 return errorHandler(error); 12 return errorHandler(error);
20 } 13 }
21 } 14 }
22 15
23 Function _registerErrorHandler(Function errorHandler, Zone zone) { 16 Function _registerErrorHandler(Function errorHandler, Zone zone) {
24 if (errorHandler is ZoneBinaryCallback) { 17 if (errorHandler is ZoneBinaryCallback) {
25 return zone.registerBinaryCallback(errorHandler); 18 return zone.registerBinaryCallback(errorHandler);
26 } else { 19 } else {
27 return zone.registerUnaryCallback(errorHandler); 20 return zone.registerUnaryCallback(errorHandler);
28 } 21 }
29 } 22 }
30 23
31 /**
32 * *DEPRECATED*. Use explicit stack trace arguments instead.
33 *
34 * Get the [StackTrace] attached to [o].
35 *
36 * If object [o] was thrown and caught in a dart:async method, a [StackTrace]
37 * object was attached to it. Use [getAttachedStackTrace] to get that object.
38 *
39 * Returns [null] if no [StackTrace] was attached.
40 */
41 @deprecated
42 getAttachedStackTrace(o) {
43 if (o == null || o is bool || o is num || o is String) return null;
44 return _stackTraceExpando[o];
45 }
46
47 class _AsyncError implements Error { 24 class _AsyncError implements Error {
48 final error; 25 final error;
49 final StackTrace stackTrace; 26 final StackTrace stackTrace;
50 27
51 _AsyncError(this.error, this.stackTrace); 28 _AsyncError(this.error, this.stackTrace);
52 } 29 }
53 30
54 class _UncaughtAsyncError extends _AsyncError { 31 class _UncaughtAsyncError extends _AsyncError {
55 _UncaughtAsyncError(error, StackTrace stackTrace) 32 _UncaughtAsyncError(error, StackTrace stackTrace)
56 : super(error, _getBestStackTrace(error, stackTrace)) { 33 : super(error, _getBestStackTrace(error, stackTrace));
57 // Clear the attached stack trace.
58 _attachStackTrace(error, null);
59 }
60 34
61 static StackTrace _getBestStackTrace(error, StackTrace stackTrace) { 35 static StackTrace _getBestStackTrace(error, StackTrace stackTrace) {
62 if (stackTrace != null) return stackTrace; 36 if (stackTrace != null) return stackTrace;
63 var trace = getAttachedStackTrace(error);
64 if (trace != null) return trace;
65 if (error is Error) { 37 if (error is Error) {
66 Error e = error; 38 return error.stackTrace;
67 return e.stackTrace;
68 } 39 }
69 return null; 40 return null;
70 } 41 }
71 42
72 String toString() { 43 String toString() {
73 String result = "Uncaught Error: ${error}"; 44 String result = "Uncaught Error: ${error}";
74 45
75 if (stackTrace != null) { 46 if (stackTrace != null) {
76 result += "\nStack Trace:\n$stackTrace"; 47 result += "\nStack Trace:\n$stackTrace";
77 } 48 }
78 return result; 49 return result;
79 } 50 }
80 } 51 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/solver/backtracking_solver.dart ('k') | sdk/lib/async/broadcast_stream_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698