Index: tool/input_sdk/patch/core_patch.dart |
diff --git a/tool/input_sdk/patch/core_patch.dart b/tool/input_sdk/patch/core_patch.dart |
index d557375c54b5bf3662b5ce40c99891fcc627bc14..52ddebdc8205f0098a60387800b92fa3c3ca3566 100644 |
--- a/tool/input_sdk/patch/core_patch.dart |
+++ b/tool/input_sdk/patch/core_patch.dart |
@@ -12,7 +12,8 @@ import 'dart:_js_helper' show patch, |
JSSyntaxRegExp, |
Primitives, |
stringJoinUnchecked, |
- objectHashCode; |
+ objectHashCode, |
+ getTraceFromException; |
import 'dart:_foreign_helper' show JS; |
@@ -458,16 +459,14 @@ class StackTrace { |
@patch |
@NoInline() |
static StackTrace get current { |
- var error = JS('', 'new Error()'); |
- var stack = JS('String|Null', '#.stack', error); |
- if (stack is String) return new StackTrace.fromString(stack); |
if (JS('', 'Error.captureStackTrace') != null) { |
+ var error = JS('', 'new Error()'); |
JS('void', 'Error.captureStackTrace(#)', error); |
- var stack = JS('String|Null', '#.stack', error); |
- if (stack is String) return new StackTrace.fromString(stack); |
+ return getTraceFromException(error); |
} |
+ // Fallback if Error.captureStackTrace does not exist. |
try { |
- throw 0; |
+ throw ''; |
} catch (_, stackTrace) { |
return stackTrace; |
} |