| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of dart._runtime; | 4 part of dart._runtime; |
| 5 | 5 |
| 6 bool _trapRuntimeErrors = true; | 6 bool _trapRuntimeErrors = true; |
| 7 bool _ignoreWhitelistedErrors = true; |
| 7 | 8 |
| 8 // Override, e.g., for testing | 9 // Override, e.g., for testing |
| 9 void trapRuntimeErrors(bool flag) { | 10 void trapRuntimeErrors(bool flag) { |
| 10 _trapRuntimeErrors = flag; | 11 _trapRuntimeErrors = flag; |
| 11 } | 12 } |
| 12 | 13 |
| 14 void ignoreWhitelistedErrors(bool flag) { |
| 15 _ignoreWhitelistedErrors = flag; |
| 16 } |
| 17 |
| 13 throwCastError(object, actual, type) => JS('', '''(() => { | 18 throwCastError(object, actual, type) => JS('', '''(() => { |
| 14 var found = $typeName($actual); | 19 var found = $typeName($actual); |
| 15 var expected = $typeName($type); | 20 var expected = $typeName($type); |
| 16 if ($_trapRuntimeErrors) debugger; | 21 if ($_trapRuntimeErrors) debugger; |
| 17 $throw_(new $CastErrorImplementation($object, found, expected)); | 22 $throw_(new $CastErrorImplementation($object, found, expected)); |
| 18 })()'''); | 23 })()'''); |
| 19 | 24 |
| 20 throwTypeError(object, actual, type) => JS('', '''(() => { | 25 throwTypeError(object, actual, type) => JS('', '''(() => { |
| 21 var found = $typeName($actual); | 26 var found = $typeName($actual); |
| 22 var expected = $typeName($type); | 27 var expected = $typeName($type); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 })()'''); | 57 })()'''); |
| 53 | 58 |
| 54 throwNullValueError() => JS('', '''(() => { | 59 throwNullValueError() => JS('', '''(() => { |
| 55 // TODO(vsm): Per spec, we should throw an NSM here. Technically, we ought | 60 // TODO(vsm): Per spec, we should throw an NSM here. Technically, we ought |
| 56 // to thread through method info, but that uglifies the code and can't | 61 // to thread through method info, but that uglifies the code and can't |
| 57 // actually be queried ... it only affects how the error is printed. | 62 // actually be queried ... it only affects how the error is printed. |
| 58 if ($_trapRuntimeErrors) debugger; | 63 if ($_trapRuntimeErrors) debugger; |
| 59 $throw_(new $NoSuchMethodError(null, | 64 $throw_(new $NoSuchMethodError(null, |
| 60 new $Symbol('<Unexpected Null Value>'), null, null, null)); | 65 new $Symbol('<Unexpected Null Value>'), null, null, null)); |
| 61 })()'''); | 66 })()'''); |
| OLD | NEW |