Index: sdk/lib/_internal/pub/lib/src/git.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/git.dart b/sdk/lib/_internal/pub/lib/src/git.dart |
index 3f61dc19823823b0faf418f1797ff93c938fc942..510ca7eecd3819dea05246c6beea8e2e6edebfab 100644 |
--- a/sdk/lib/_internal/pub/lib/src/git.dart |
+++ b/sdk/lib/_internal/pub/lib/src/git.dart |
@@ -11,6 +11,22 @@ import 'dart:io'; |
import 'io.dart'; |
import 'log.dart' as log; |
+/// An exception thrown because a git command failed. |
+class GitException implements Exception { |
Bob Nystrom
2014/04/01 23:43:34
I think we tend to import this library with a pref
nweiz
2014/04/02 00:41:19
I think shadowing core types is worse than having
|
+ /// The arguments to the git command. |
+ final List<String> args; |
+ |
+ /// The standard error emitted by git. |
+ final String stderr; |
+ |
+ String get message => 'Git error. Command: git ${args.join(" ")}\n$stderr'; |
+ |
+ GitException(Iterable<String> args, this.stderr) |
+ : args = args.toList(); |
+ |
+ String toString() => message; |
+} |
+ |
/// Tests whether or not the git command-line app is available for use. |
Future<bool> get isInstalled { |
if (_isGitInstalledCache != null) { |
@@ -28,10 +44,7 @@ Future<List<String>> run(List<String> args, |
return runProcess(git, args, workingDir: workingDir, |
environment: environment); |
}).then((result) { |
- if (!result.success) throw new Exception( |
- 'Git error. Command: git ${args.join(" ")}\n' |
- '${result.stderr.join("\n")}'); |
- |
+ if (!result.success) throw new GitException(args, result.stderr.join("\n")); |
return result.stdout; |
}); |
} |