mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:17:14 +00:00
dart2js: reuse stack trace on rethrow
BUG= dartbug.com/15171 R=sigurdm@google.com Review URL: https://codereview.chromium.org//1152023004
This commit is contained in:
parent
2c533ac971
commit
1763aa3467
|
@ -2052,7 +2052,11 @@ StackTrace getTraceFromException(exception) {
|
|||
if (exception is ExceptionAndStackTrace) {
|
||||
return exception.stackTrace;
|
||||
}
|
||||
return new _StackTrace(exception);
|
||||
if (exception == null) return new _StackTrace(exception);
|
||||
_StackTrace trace = JS('_StackTrace|Null', r'#.$cachedTrace', exception);
|
||||
if (trace != null) return trace;
|
||||
trace = new _StackTrace(exception);
|
||||
return JS('_StackTrace', r'#.$cachedTrace = #', exception, trace);
|
||||
}
|
||||
|
||||
class _StackTrace implements StackTrace {
|
||||
|
|
23
tests/compiler/dart2js_extra/identical_trace_test.dart
Normal file
23
tests/compiler/dart2js_extra/identical_trace_test.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
var st1;
|
||||
try {
|
||||
try {
|
||||
throw 'bad';
|
||||
} catch (e, st) {
|
||||
st1 = st;
|
||||
rethrow;
|
||||
}
|
||||
Expect.fail('Exception expected');
|
||||
} catch (e, st2) {
|
||||
Expect.equals(st1, st2);
|
||||
Expect.identical(st1, st2);
|
||||
return;
|
||||
}
|
||||
Expect.fail('Exception expected');
|
||||
}
|
Loading…
Reference in a new issue