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

Unified Diff: utils/pub/pub.dart

Issue 10752013: Add a --trace flag to make Pub print a stack trace on error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « no previous file | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
}
/**
« no previous file with comments | « no previous file | utils/tests/pub/pub_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698