Chromium Code Reviews| Index: utils/pub/pub.dart |
| diff --git a/utils/pub/pub.dart b/utils/pub/pub.dart |
| index adbe5ea616dab07cab3c89676bf52f93176f548b..c01657d2df706c1620d90ee76cf6c37d318202bd 100644 |
| --- a/utils/pub/pub.dart |
| +++ b/utils/pub/pub.dart |
| @@ -48,6 +48,7 @@ main() { |
| parser.addOption('cachedir', help: 'The directory containing the system-wide ' |
| 'Pub cache'); |
| parser.addOption('sdkdir', help: 'The directory containing the Dart SDK'); |
| + parser.addFlag('trace', help: 'Prints a stack trace when an error occurs'); |
| var results; |
| try { |
| @@ -83,7 +84,8 @@ main() { |
| return; |
| } |
| - command.run(cache, results.rest.getRange(1, results.rest.length - 1)); |
| + var args = results.rest.getRange(1, results.rest.length - 1); |
| + command.run(cache, results, args); |
|
Bob Nystrom
2012/07/09 23:00:36
These names aren't very clear. How about:
results
nweiz
2012/07/09 23:38:09
Done.
|
| } |
| /** Displays usage information for the app. */ |
| @@ -128,13 +130,13 @@ class PubCommand { |
| abstract String get description(); |
| - void run(SystemCache cache_, List<String> args) { |
| + void run(SystemCache cache_, ArgResults options, List<String> args) { |
| cache = cache_; |
| // TODO(rnystrom): Each command should define the arguments it expects and |
| // we can handle them generically here. |
| - handleError(error) { |
| + handleError(error, trace) { |
| // This is basically the top-level exception handler so that we don't |
| // spew a stack trace on our users. |
| // TODO(rnystrom): Add --trace flag so stack traces can be enabled for |
| @@ -148,13 +150,16 @@ class PubCommand { |
| } |
| printError(message); |
| + if (options['trace'] && trace != null) { |
| + printError(trace); |
| + } |
| return true; |
| } |
| // TODO(rnystrom): Will eventually need better logic to walk up |
| // subdirectories until we hit one that looks package-like. For now, just |
| // assume the cwd is it. |
| - Package.load(workingDir, cache.sources).chain((package) { |
| + var future = Package.load(workingDir, cache.sources).chain((package) { |
| entrypoint = new Entrypoint(package, cache); |
| try { |
| @@ -162,11 +167,12 @@ class PubCommand { |
| if (commandFuture == null) return new Future.immediate(true); |
| return commandFuture; |
| - } catch (var error) { |
| - handleError(error); |
| + } catch (var error, var trace) { |
| + handleError(error, trace); |
| return new Future.immediate(null); |
| } |
| - }).handleException(handleError); |
| + }); |
| + future.handleException((e) => handleError(e, future.stackTrace)); |
| } |
| /** |