Index: sdk/lib/_internal/pub/lib/src/command.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/command.dart b/sdk/lib/_internal/pub/lib/src/command.dart |
index 6b043547bcb6f5c17b2fc2bfc80a286167696f25..6bc10b0e2fc99d0349bb09569da759bee37b57a4 100644 |
--- a/sdk/lib/_internal/pub/lib/src/command.dart |
+++ b/sdk/lib/_internal/pub/lib/src/command.dart |
@@ -25,7 +25,6 @@ import 'command/uploader.dart'; |
import 'command/version.dart'; |
import 'entrypoint.dart'; |
import 'exceptions.dart'; |
-import 'exit_codes.dart' as exit_codes; |
import 'log.dart' as log; |
import 'global_packages.dart'; |
import 'system_cache.dart'; |
@@ -68,7 +67,7 @@ abstract class PubCommand { |
/// [commands]. |
static void usageErrorWithCommands(Map<String, PubCommand> commands, |
String message) { |
- throw new UsageException(message, _listCommands(commands)); |
+ throw new UsageException(message)..bindUsage(_listCommands(commands)); |
} |
/// Writes [commands] in a nicely formatted list to [buffer]. |
@@ -191,7 +190,10 @@ abstract class PubCommand { |
entrypoint = new Entrypoint(path.current, cache); |
} |
- return syncFuture(onRun); |
+ return syncFuture(onRun).catchError((error) { |
+ if (error is UsageException) error.bindUsage(_getUsage()); |
+ throw error; |
+ }); |
} |
/// Override this to perform the specific command. |
@@ -214,13 +216,6 @@ abstract class PubCommand { |
log.message('$description\n\n${_getUsage()}'); |
} |
- // TODO(rnystrom): Use this in other places handle usage failures. |
- /// Throw a [UsageException] for a usage error of this command with |
- /// [message]. |
- void usageError(String message) { |
- throw new UsageException(message, _getUsage()); |
- } |
- |
/// Parses a user-supplied integer [intString] named [name]. |
/// |
/// If the parsing fails, prints a usage message and exits. |