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

Issue 16154017: Rename RuntimeError to CyclicIntializationError, as per spec. (Closed)

Created:
7 years, 6 months ago by Lasse Reichstein Nielsen
Modified:
7 years, 6 months ago
Reviewers:
Johnni Winther
CC:
reviews_dartlang.org, floitsch, regis, ahe
Visibility:
Public.

Description

Rename RuntimeError to CyclicIntializationError, as per spec. The RuntimeError has been used to report cyclic initialization errors in dart2js. It has also been used for other, unrelated, uses, where it makes little to no sense. The RuntimeError type has been removed, but added in js_helper.dart, where dart2js uses it. Uses of new RuntimeError("some message") have been converted to other errors (Argument/State/Unsupported). In some cases, just throwing a String might have been just as good. BUG=http://dartbug.com/11040 R=johnniwinther@google.com Committed: https://code.google.com/p/dart/source/detail?r=23584

Patch Set 1 #

Total comments: 6

Patch Set 2 : Fix bad merge in js_helper.dart #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+58 lines, -41 lines) Patch
M runtime/bin/vmstats/bargraph.dart View 1 chunk +1 line, -1 line 0 comments Download
M runtime/tests/vm/dart/isolate_unhandled_exception_test.dart View 1 chunk +1 line, -1 line 0 comments Download
M runtime/tests/vm/dart/isolate_unhandled_exception_test2.dart View 1 chunk +1 line, -1 line 0 comments Download
M runtime/tests/vm/dart/isolate_unhandled_exception_uri_helper.dart View 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/snapshot_test.cc View 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/snapshot_test.dart View 1 chunk +1 line, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/lib/js_helper.dart View 1 1 chunk +11 lines, -1 line 0 comments Download
M sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart View 2 chunks +2 lines, -2 lines 6 comments Download
M sdk/lib/core/errors.dart View 1 1 chunk +12 lines, -5 lines 0 comments Download
M tests/isolate/global_error_handler2_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/isolate/global_error_handler_stream2_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/isolate/global_error_handler_stream_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/isolate/global_error_handler_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/language/lazy_static3_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/lib/async/run_async4_test.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M tests/standalone/io/process_non_ascii_test.dart View 1 chunk +1 line, -1 line 0 comments Download
M tests/standalone/io/test_extension_fail_test.dart View 3 chunks +5 lines, -5 lines 0 comments Download
M tests/standalone/io/test_extension_fail_tester.dart View 1 chunk +1 line, -1 line 0 comments Download
M tests/standalone/io/test_extension_tester.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M tools/testing/dart/status_expression.dart View 4 chunks +6 lines, -6 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Lasse Reichstein Nielsen
@regis: This adds the exception to throw on circular initialization (per TODO in parser.cc).
7 years, 6 months ago (2013-06-04 09:42:13 UTC) #1
Johnni Winther
https://codereview.chromium.org/16154017/diff/1/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart File sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (right): https://codereview.chromium.org/16154017/diff/1/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart#newcode1468 sdk/lib/_internal/compiler/implementation/lib/js_helper.dart:1468: */ What is the reason for all the changes ...
7 years, 6 months ago (2013-06-04 09:58:52 UTC) #2
Lasse Reichstein Nielsen
ptal https://codereview.chromium.org/16154017/diff/1/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart File sdk/lib/_internal/compiler/implementation/lib/js_helper.dart (right): https://codereview.chromium.org/16154017/diff/1/sdk/lib/_internal/compiler/implementation/lib/js_helper.dart#newcode1468 sdk/lib/_internal/compiler/implementation/lib/js_helper.dart:1468: */ Looks like a really bad merge. https://codereview.chromium.org/16154017/diff/1/tests/language/lazy_static3_test.dart ...
7 years, 6 months ago (2013-06-04 10:21:07 UTC) #3
Johnni Winther
lgtm
7 years, 6 months ago (2013-06-04 10:28:50 UTC) #4
Lasse Reichstein Nielsen
Committed patchset #2 manually as r23584 (presubmit successful).
7 years, 6 months ago (2013-06-04 10:33:29 UTC) #5
ahe
https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart File sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart (right): https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart#newcode431 sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart:431: throw new ArgumentError('Bad field descriptor: $descriptor'); What makes you ...
7 years, 6 months ago (2013-06-04 13:14:11 UTC) #6
Lasse Reichstein Nielsen
https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart File sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart (right): https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart#newcode431 sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart:431: throw new ArgumentError('Bad field descriptor: $descriptor'); Descriptor is an ...
7 years, 6 months ago (2013-06-13 08:08:57 UTC) #7
ahe
7 years, 6 months ago (2013-06-13 09:59:14 UTC) #8
Message was sent while issue was closed.
Lasse,

Sorry, you found one of my many pet peeves ;-)

Cheers,
Peter

https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/i...
File sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart (right):

https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/i...
sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart:431: throw new
ArgumentError('Bad field descriptor: $descriptor');
On 2013/06/13 08:08:57, Lasse Reichstein Nielsen wrote:
> Descriptor is an argument. It's being tested in some way, and if it doesn't
> satisfy the test, an error is thrown that says that the descriptor is bad.
> That sounds like an argument error.
> Could be wrong ofcourse, and you are free to find another error to use.

I'm sorry, I'm on a crusade against incorrect uses of "generic" exceptions: any
exception thrown gets exposed to the user because it bubbles up through the call
stack. So I think it is important that the exception conveys the right message.

The message an ArgumentError coveys is that the user provided a wrong argument
to a method (or factory). However, this factory is not accessible to users and
the user has no control over the descriptor argument, and this exception might
occur when a user writes code like this:

someClassMirror.variables

There are no arguments here, but an internal error might happen at runtime, and
I need to know the descriptor to debug the problem. The users can't fix it
themselves: there's nothing wrong with any arguments (a getter doesn't take
arguments).

https://codereview.chromium.org/16154017/diff/22/sdk/lib/_internal/compiler/i...
sdk/lib/_internal/compiler/implementation/lib/js_mirrors.dart:484: throw new
ArgumentError('Cannot find callName on "$reflectee"');
On 2013/06/13 08:08:57, Lasse Reichstein Nielsen wrote:
> True, I probably misread the code due to the inlined code-as-text above.
> Looks more like a StateError.

This is what StateError says it represents: "The operation was not allowed by
the current state of the object."

See above rant: the user has done nothing to put the JsClosureMirror in a bad
state, and cannot do anything to bring it to a different state.  The object has
no states besides being there or not (all fields are final, and all fields refer
to immutable objects).

You can only obtain an instance of this object by calling "reflect(foo)" where
foo is a closure.  If it is not a closure, reflect will return a
JsInstanceMirror.

This represents an internal error in the runtime implementation of the Dart
platform.  I think RuntimeError (or a string) conveys that much better than
StateError.

Powered by Google App Engine
This is Rietveld 408576698