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

Unified Diff: runtime/observatory/lib/src/cli/command.dart

Issue 2552783003: Better reporting of ambiguous and "not found" commands in Obs debugger. (Closed)
Patch Set: Better reporting of ambiguous and "not found" commands in Obs debugger. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/debugger.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/cli/command.dart
diff --git a/runtime/observatory/lib/src/cli/command.dart b/runtime/observatory/lib/src/cli/command.dart
index 28ffbff326aec0df7f3ddf13913a7b169ac2588c..6030aef8ca6e96830bad98739e269fa1be85677f 100644
--- a/runtime/observatory/lib/src/cli/command.dart
+++ b/runtime/observatory/lib/src/cli/command.dart
@@ -176,13 +176,11 @@ class RootCommand extends _CommandBase {
var args = _splitLine(line);
var commands = _match(args, true);
if (commands.isEmpty) {
- // TODO(turnidge): Add a proper exception class for this.
- return new Future.error('No such command');
+ return new Future.error(new NoSuchCommandException(line));
} else if (commands.length == 1) {
return commands[0].run(args.sublist(commands[0]._depth));
} else {
- // TODO(turnidge): Add a proper exception class for this.
- return new Future.error('Ambiguous command');
+ return new Future.error(new AmbiguousCommandException(line, commands));
}
}
@@ -254,3 +252,29 @@ abstract class Command extends _CommandBase {
toString() => 'Command(${name})';
}
+
+abstract class CommandException implements Exception {
+}
+
+class AmbiguousCommandException extends CommandException {
+ AmbiguousCommandException(this.command, this.matches);
+
+ final String command;
+ final List<Command> matches;
+
+ @override
+ String toString() {
+ List<String> matchNames = matches.map(
+ (Command command) => '${command.fullName}').toList();
+ return "Command '$command' is ambiguous: $matchNames";
+ }
+}
+
+class NoSuchCommandException extends CommandException {
+ NoSuchCommandException(this.command);
+
+ final String command;
+
+ @override
+ String toString() => "No such command: '$command'";
+}
« no previous file with comments | « no previous file | runtime/observatory/lib/src/elements/debugger.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698