| Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
|
| diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
|
| index 0f8d0b407f7c1577156d7aa6c405b79e426da9c4..49bc1cc11afb09fdf88249a0a93b02af77434ae4 100644
|
| --- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
|
| +++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/errors.dart
|
| @@ -3,41 +3,48 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
| part of dart._runtime;
|
|
|
| +bool _trapRuntimeErrors = true;
|
| +
|
| +// Override, e.g., for testing
|
| +void trapRuntimeErrors(bool flag) {
|
| + _trapRuntimeErrors = flag;
|
| +}
|
| +
|
| throwCastError(object, actual, type) => JS('', '''(() => {
|
| - debugger;
|
| - $throw_(new $CastErrorImplementation($object,
|
| - $typeName($actual),
|
| - $typeName($type)));
|
| + var found = $typeName($actual);
|
| + var expected = $typeName($type);
|
| + if ($_trapRuntimeErrors) debugger;
|
| + $throw_(new $CastErrorImplementation($object, found, expected));
|
| })()''');
|
|
|
| throwTypeError(object, actual, type) => JS('', '''(() => {
|
| - debugger;
|
| - $throw_(new $TypeErrorImplementation($object,
|
| - $typeName($actual),
|
| - $typeName($type)));
|
| + var found = $typeName($actual);
|
| + var expected = $typeName($type);
|
| + if ($_trapRuntimeErrors) debugger;
|
| + $throw_(new $TypeErrorImplementation($object, found, expected));
|
| })()''');
|
|
|
| throwStrongModeCastError(object, actual, type) => JS('', '''(() => {
|
| - debugger;
|
| - $throw_(new $StrongModeCastError($object,
|
| - $typeName($actual),
|
| - $typeName($type)));
|
| + var found = $typeName($actual);
|
| + var expected = $typeName($type);
|
| + if ($_trapRuntimeErrors) debugger;
|
| + $throw_(new $StrongModeCastError($object, found, expected));
|
| })()''');
|
|
|
| throwStrongModeTypeError(object, actual, type) => JS('', '''(() => {
|
| - debugger;
|
| - $throw_(new $StrongModeTypeError($object,
|
| - $typeName($actual),
|
| - $typeName($type)));
|
| + var found = $typeName($actual);
|
| + var expected = $typeName($type);
|
| + if ($_trapRuntimeErrors) debugger;
|
| + $throw_(new $StrongModeTypeError($object, found, expected));
|
| })()''');
|
|
|
| throwUnimplementedError(message) => JS('', '''(() => {
|
| - debugger;
|
| + if ($_trapRuntimeErrors) debugger;
|
| $throw_(new $UnimplementedError($message));
|
| })()''');
|
|
|
| throwAssertionError([message]) => JS('', '''(() => {
|
| - debugger;
|
| + if ($_trapRuntimeErrors) debugger;
|
| let error = $message != null
|
| ? new $AssertionErrorWithMessage($message())
|
| : new $AssertionError();
|
| @@ -48,7 +55,7 @@ throwNullValueError() => JS('', '''(() => {
|
| // TODO(vsm): Per spec, we should throw an NSM here. Technically, we ought
|
| // to thread through method info, but that uglifies the code and can't
|
| // actually be queried ... it only affects how the error is printed.
|
| - debugger;
|
| + if ($_trapRuntimeErrors) debugger;
|
| $throw_(new $NoSuchMethodError(null,
|
| new $Symbol('<Unexpected Null Value>'), null, null, null));
|
| })()''');
|
|
|