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

Unified Diff: sdk/lib/_internal/pub/lib/src/command.dart

Issue 372123002: Get rid of deferred binding for usage errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
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 5f0df64ae1daee3acc16c1d281e46c36e43b54da..1f5ac2a872f2c57708853ac44aa59247f373094a 100644
--- a/sdk/lib/_internal/pub/lib/src/command.dart
+++ b/sdk/lib/_internal/pub/lib/src/command.dart
@@ -67,7 +67,7 @@ abstract class PubCommand {
/// [commands].
static void usageErrorWithCommands(Map<String, PubCommand> commands,
String message) {
- throw new UsageException(message)..bindUsage(_listCommands(commands));
+ throw new UsageException(message, _listCommands(commands));
}
/// Writes [commands] in a nicely formatted list to [buffer].
@@ -190,10 +190,7 @@ abstract class PubCommand {
entrypoint = new Entrypoint(path.current, cache);
}
- return syncFuture(onRun).catchError((error) {
- if (error is UsageException) error.bindUsage(_getUsage());
- throw error;
- });
+ return syncFuture(onRun);
}
/// Override this to perform the specific command.
@@ -216,6 +213,12 @@ abstract class PubCommand {
log.message('$description\n\n${_getUsage()}');
}
+ /// 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.
@@ -227,11 +230,6 @@ abstract class PubCommand {
}
}
- /// Fails with a usage error [message] for this command.
- void usageError(String message) {
- throw new UsageException(message)..bindUsage(_getUsage());
- }
-
/// Generates a string of usage information for this command.
String _getUsage() {
var buffer = new StringBuffer();
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/command/global_run.dart » ('j') | sdk/lib/_internal/pub/lib/src/utils.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698