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

Side by Side Diff: sdk/lib/core/stacktrace.dart

Issue 1448003002: Add StackTrace.current getter. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * An interface implemented by all stack trace objects. 8 * An interface implemented by all stack trace objects.
9 * 9 *
10 * A [StackTrace] is intended to convey information to the user about the call 10 * A [StackTrace] is intended to convey information to the user about the call
(...skipping 13 matching lines...) Expand all
24 * 24 *
25 * The `stackTraceString` can be a string returned by some other 25 * The `stackTraceString` can be a string returned by some other
26 * stack trace, or it can be any string at all. 26 * stack trace, or it can be any string at all.
27 * If the string doesn't look like a stack trace, code that interprets 27 * If the string doesn't look like a stack trace, code that interprets
28 * stack traces is likely to fail, so fake stack traces should be used 28 * stack traces is likely to fail, so fake stack traces should be used
29 * with care. 29 * with care.
30 */ 30 */
31 factory StackTrace.fromString(String stackTraceString) = _StringStackTrace; 31 factory StackTrace.fromString(String stackTraceString) = _StringStackTrace;
32 32
33 /** 33 /**
34 * Returns a representation of the current stack trace.
35 *
36 * This is similar to what can be achieved by doing:
37 *
38 * try { throw 0; } catch (_, stack) { return stack; }
kevmoo 2015/11/17 18:51:44 Please use ```dart try { throw 0; } ... ``` synta
sra1 2015/11/17 19:13:44 Shouldn't that be the default for Dart documentati
floitsch 2015/11/17 23:22:32 There should be no need to specify "dart" as infor
Lasse Reichstein Nielsen 2015/11/18 10:11:39 I fail to see the improvement of * ```dart * try
39 *
40 * but the getter tries to get the stack without throwing any object
floitsch 2015/11/16 19:30:21 This won't read nice in a formatted output. Just m
Lasse Reichstein Nielsen 2015/11/18 10:11:39 Done.
41 * if it can be avoided.
42 */
43 external static StackTrace get current;
44
45 /**
34 * Returns a [String] representation of the stack trace. 46 * Returns a [String] representation of the stack trace.
35 * 47 *
36 * The string represents the full stack trace starting from 48 * The string represents the full stack trace starting from
37 * the point where a throw ocurred to the top of the current call sequence. 49 * the point where a throw ocurred to the top of the current call sequence.
38 * 50 *
39 * The exact format of the string representation is not final. 51 * The exact format of the string representation is not final.
40 */ 52 */
41 String toString(); 53 String toString();
42 } 54 }
43 55
44 class _StringStackTrace implements StackTrace { 56 class _StringStackTrace implements StackTrace {
45 final String _stackTrace; 57 final String _stackTrace;
46 _StringStackTrace(this._stackTrace); 58 _StringStackTrace(this._stackTrace);
47 String toString() => _stackTrace; 59 String toString() => _stackTrace;
48 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698