Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tool/input_sdk/private/ddc_runtime/errors.dart

Issue 2026133002: Throw TypeError instead of CastError for type coercions. (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 throwCastError(actual, type) => JS('', '''(() => { 6 throwCastError(object, actual, type) => JS('', '''(() => {
7 $throw_(new $CastErrorImplementation($typeName($actual), 7 $throw_(new $CastErrorImplementation($object,
8 $typeName($actual),
8 $typeName($type))); 9 $typeName($type)));
9 })()'''); 10 })()''');
10 11
12 throwTypeError(object, actual, type) => JS('', '''(() => {
13 $throw_(new $TypeErrorImplementation($object,
14 $typeName($actual),
15 $typeName($type)));
16 })()''');
17
18 throwStrongModeCastError(object, actual, type) => JS('', '''(() => {
19 $throw_(new $StrongModeCastError($object,
20 $typeName($actual),
21 $typeName($type)));
22 })()''');
23
24 throwStrongModeTypeError(object, actual, type) => JS('', '''(() => {
25 $throw_(new $StrongModeTypeError($object,
26 $typeName($actual),
27 $typeName($type)));
28 })()''');
29
11 throwAssertionError() => JS('', '''(() => { 30 throwAssertionError() => JS('', '''(() => {
12 $throw_(new $AssertionError()); 31 $throw_(new $AssertionError());
13 })()'''); 32 })()''');
14 33
15 throwNullValueError() => JS('', '''(() => { 34 throwNullValueError() => JS('', '''(() => {
16 // TODO(vsm): Per spec, we should throw an NSM here. Technically, we ought 35 // TODO(vsm): Per spec, we should throw an NSM here. Technically, we ought
17 // to thread through method info, but that uglifies the code and can't 36 // to thread through method info, but that uglifies the code and can't
18 // actually be queried ... it only affects how the error is printed. 37 // actually be queried ... it only affects how the error is printed.
19 $throw_(new $NoSuchMethodError(null, 38 $throw_(new $NoSuchMethodError(null,
20 new $Symbol('<Unexpected Null Value>'), null, null, null)); 39 new $Symbol('<Unexpected Null Value>'), null, null, null));
21 })()'''); 40 })()''');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698