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 ccd54d0ea3d66c24aa87c4f618087b6223f0adf0..daa1a6b23a0be52989c2f1b239c77dfdff19c20a 100644 |
--- a/sdk/lib/_internal/pub/lib/src/command.dart |
+++ b/sdk/lib/_internal/pub/lib/src/command.dart |
@@ -191,7 +191,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 +217,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. |