OLD | NEW |
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"); | 7 final Expando _stackTraceExpando = new Expando("asynchronous error"); |
8 | 8 |
9 void _attachStackTrace(o, st) { | 9 void _attachStackTrace(o, st) { |
10 if (o == null || o is bool || o is num || o is String) return; | 10 if (o == null || o is bool || o is num || o is String) return; |
11 _stackTraceExpando[o] = st; | 11 _stackTraceExpando[o] = st; |
12 } | 12 } |
13 | 13 |
14 /** | 14 /** |
15 * *This is an experimental API.* | 15 * *DEPRECATED*. Use explicit stack trace arguments instead. |
16 * | 16 * |
17 * Get the [StackTrace] attached to [o]. | 17 * Get the [StackTrace] attached to [o]. |
18 * | 18 * |
19 * If object [o] was thrown and caught in a dart:async method, a [StackTrace] | 19 * If object [o] was thrown and caught in a dart:async method, a [StackTrace] |
20 * object was attached to it. Use [getAttachedStackTrace] to get that object. | 20 * object was attached to it. Use [getAttachedStackTrace] to get that object. |
21 * | 21 * |
22 * Returns [null] if no [StackTrace] was attached. | 22 * Returns [null] if no [StackTrace] was attached. |
23 */ | 23 */ |
| 24 @deprecated |
24 getAttachedStackTrace(o) { | 25 getAttachedStackTrace(o) { |
25 if (o == null || o is bool || o is num || o is String) return null; | 26 if (o == null || o is bool || o is num || o is String) return null; |
26 return _stackTraceExpando[o]; | 27 return _stackTraceExpando[o]; |
27 } | 28 } |
28 | 29 |
29 // TODO(floitsch): should we make this an Error class? Probably depends, if we | 30 // TODO(floitsch): should we make this an Error class? Probably depends, if we |
30 // want to make the class public. | 31 // want to make the class public. |
31 class _AsyncError { | 32 class _AsyncError { |
32 final error; | 33 final error; |
33 final StackTrace stackTrace; | 34 final StackTrace stackTrace; |
(...skipping 11 matching lines...) Expand all Loading... |
45 | 46 |
46 // Clear the attached stack trace. | 47 // Clear the attached stack trace. |
47 _attachStackTrace(error, null); | 48 _attachStackTrace(error, null); |
48 | 49 |
49 if (trace != null) { | 50 if (trace != null) { |
50 result += "\nStack Trace:\n$trace"; | 51 result += "\nStack Trace:\n$trace"; |
51 } | 52 } |
52 return result; | 53 return result; |
53 } | 54 } |
54 } | 55 } |
OLD | NEW |