Skip to content

Commit

Permalink
In observatory use ArgumentError instead of FallThroughError
Browse files Browse the repository at this point in the history
Throwing a programmer-constructed FallThroughError is not useful.  It
prints something like:

    'null': Switch case fall-through at line null.

And if you can track that down, it's confusing because it's being used
to signal things that don't have anything to do with falling through
from one switch case to the next one.  Usually, there turns out to be
no matching case in the first place so there's no possible way that
anything fell through to the next case.

Fixes #28189

Change-Id: I68d8aaf22c95163f87a159928f924c25c19f094e
Reviewed-on: https://dart-review.googlesource.com/62522
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Kevin Millikin <kmillikin@google.com>
  • Loading branch information
Kevin Millikin authored and commit-bot@chromium.org committed Jun 28, 2018
1 parent bd9aa51 commit 29924c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion runtime/observatory/lib/src/app/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class ObservatoryApplication {
return;
}
}
throw new FallThroughError();
throw new ArgumentError.value(uri, 'uri');
}

/// Set the Observatory application page.
Expand Down
30 changes: 18 additions & 12 deletions runtime/observatory/lib/src/service/object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2114,8 +2114,9 @@ M.ErrorKind stringToErrorKind(String value) {
case 'TerminationError':
return M.ErrorKind.terminationError;
}
Logger.root.severe('Unrecognized error kind: $value');
throw new FallThroughError();
var message = 'Unrecognized error kind: $value';
Logger.root.severe(message);
throw new ArgumentError(message);
}

/// A [DartError] is peered to a Dart Error object.
Expand Down Expand Up @@ -2747,8 +2748,9 @@ M.InstanceKind stringToInstanceKind(String s) {
case 'BoundedType':
return M.InstanceKind.boundedType;
}
Logger.root.severe("Unrecognized InstanceKind: '$s'");
throw new FallThroughError();
var message = 'Unrecognized instance kind: $s';
Logger.root.severe(message);
throw new ArgumentError(message);
}

class Guarded<T extends ServiceObject> implements M.Guarded<T> {
Expand Down Expand Up @@ -3115,8 +3117,9 @@ M.FunctionKind stringToFunctionKind(String value) {
case 'DynamicInvocationForwarder':
return M.FunctionKind.dynamicInvocationForwarder;
}
Logger.root.severe('Unrecognized function kind: $value');
throw new FallThroughError();
var message = 'Unrecognized function kind: $value';
Logger.root.severe(message);
throw new ArgumentError(message);
}

class ServiceFunction extends HeapObject implements M.ServiceFunction {
Expand Down Expand Up @@ -3220,8 +3223,9 @@ M.SentinelKind stringToSentinelKind(String s) {
case 'Free':
return M.SentinelKind.free;
}
Logger.root.severe("Unrecognized SentinelKind: '$s'");
throw new FallThroughError();
var message = 'Unrecognized sentinel kind: $s';
Logger.root.severe(message);
throw new ArgumentError(message);
}

class Sentinel extends ServiceObject implements M.Sentinel {
Expand Down Expand Up @@ -4234,8 +4238,9 @@ M.CodeKind stringToCodeKind(String s) {
} else if (s == 'Stub') {
return M.CodeKind.stub;
}
Logger.root.severe("Unrecognized code kind: '$s'");
throw new FallThroughError();
var message = 'Unrecognized code kind: $s';
Logger.root.severe(message);
throw new ArgumentError(message);
}

class CodeInlineInterval {
Expand Down Expand Up @@ -4475,8 +4480,9 @@ class SocketKind {
} else if (s == 'Internal') {
return Internal;
}
Logger.root.warning('Unknown socket kind $s');
throw new FallThroughError();
var message = 'Unrecognized socket kind: $s';
Logger.root.warning(message);
throw new ArgumentError(message);
}

static const Listening = const SocketKind._internal('Listening');
Expand Down

0 comments on commit 29924c4

Please sign in to comment.