Chromium Code Reviews| Index: sdk/lib/_internal/js_runtime/lib/core_patch.dart |
| diff --git a/sdk/lib/_internal/js_runtime/lib/core_patch.dart b/sdk/lib/_internal/js_runtime/lib/core_patch.dart |
| index 301517ee669f5a532008375f12048c4f37bc0ba0..b448327caa13ab4f816e461a623b30eb75068822 100644 |
| --- a/sdk/lib/_internal/js_runtime/lib/core_patch.dart |
| +++ b/sdk/lib/_internal/js_runtime/lib/core_patch.dart |
| @@ -671,3 +671,22 @@ class _Resource implements Resource { |
| }); |
| } |
| } |
| + |
| +@patch |
| +class StackTrace { |
| + @patch static StackTrace get current { |
| + var error = JS("Object", "new Error()"); |
|
sra1
2015/11/17 19:11:37
Don't use "Object".
That means any subclass of Obj
Lasse Reichstein Nielsen
2015/11/18 10:11:39
Done
|
| + var stack = JS("Object", "#.stack", error); |
|
sra1
2015/11/17 19:11:37
The type here should be 'String|Null'.
That will g
Lasse Reichstein Nielsen
2015/11/18 10:11:39
Done.
|
| + if (stack != null) return new StackTrace.fromString(stack); |
|
sra1
2015/11/17 19:11:37
It would be a little safer for this test to be 'is
Lasse Reichstein Nielsen
2015/11/18 10:11:39
Done
|
| + if (JS("Object", "Error.captureStackTrace") != null) { |
| + JS("void", "Error.captureStackTrace(#)", error); |
| + var stack = JS("Object", "#.stack", error); |
|
sra1
2015/11/17 19:11:37
'String|Null'
Lasse Reichstein Nielsen
2015/11/18 10:11:39
Done.
Lasse Reichstein Nielsen
2015/11/18 10:11:39
Done.
|
| + if (stack != null) return new StackTrace.fromString(stack); |
| + } |
| + try { |
| + throw 0; |
|
floitsch
2015/11/16 19:30:21
Which browsers still need this?
Lasse Reichstein Nielsen
2015/11/17 13:18:53
IE11 as far as I can see. Don't know about Safari
|
| + } catch (_, stackTrace) { |
| + return stackTrace; |
|
sra1
2015/11/17 19:11:37
This there a measurable performance benefit over s
Lasse Reichstein Nielsen
2015/11/18 10:11:39
It's not about performance, but about not interfer
|
| + } |
| + } |
| +} |