OLD | NEW |
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 library _js_helper; | 5 library _js_helper; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, | 8 import 'dart:_foreign_helper' show DART_CLOSURE_TO_JS, |
9 JS, | 9 JS, |
10 JS_CALL_IN_ISOLATE, | 10 JS_CALL_IN_ISOLATE, |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 // Just return the exception. We should not wrap it because in case | 1413 // Just return the exception. We should not wrap it because in case |
1414 // the exception comes from the DOM, it is a JavaScript | 1414 // the exception comes from the DOM, it is a JavaScript |
1415 // object backed by a native Dart class. | 1415 // object backed by a native Dart class. |
1416 return ex; | 1416 return ex; |
1417 } | 1417 } |
1418 | 1418 |
1419 /** | 1419 /** |
1420 * Called by generated code to fetch the stack trace from an | 1420 * Called by generated code to fetch the stack trace from an |
1421 * exception. Should never return null. | 1421 * exception. Should never return null. |
1422 */ | 1422 */ |
1423 StackTrace getTraceFromException(exception) => new _StackTrace(exception); | 1423 StackTrace getTraceFromException(exception) { |
| 1424 if (exception == null) return new _StackTrace(exception); |
| 1425 _StackTrace trace = JS('_StackTrace|Null', r'#.$cachedTrace', exception); |
| 1426 if (trace != null) return trace; |
| 1427 trace = new _StackTrace(exception); |
| 1428 return JS('_StackTrace', r'#.$cachedTrace = #', exception, trace); |
| 1429 } |
1424 | 1430 |
1425 class _StackTrace implements StackTrace { | 1431 class _StackTrace implements StackTrace { |
1426 var _exception; | 1432 var _exception; |
1427 String _trace; | 1433 String _trace; |
1428 _StackTrace(this._exception); | 1434 _StackTrace(this._exception); |
1429 | 1435 |
1430 String toString() { | 1436 String toString() { |
1431 if (_trace != null) return _trace; | 1437 if (_trace != null) return _trace; |
1432 | 1438 |
1433 String trace; | 1439 String trace; |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2012 } | 2018 } |
2013 | 2019 |
2014 /** | 2020 /** |
2015 * Error thrown when a runtime error occurs. | 2021 * Error thrown when a runtime error occurs. |
2016 */ | 2022 */ |
2017 class RuntimeError extends Error { | 2023 class RuntimeError extends Error { |
2018 final message; | 2024 final message; |
2019 RuntimeError(this.message); | 2025 RuntimeError(this.message); |
2020 String toString() => "RuntimeError: $message"; | 2026 String toString() => "RuntimeError: $message"; |
2021 } | 2027 } |
OLD | NEW |