summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-01-21 23:46:37 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-21 23:46:37 +0100
commitc6bd13922f71df6c2146025b15ed757f118afc04 (patch)
tree690e9f8772a8613ac72a2c41a70019ac1d557580
parentb33124c0eed13a93f5b93e47a2f6596c5adca482 (diff)
downloadjgit-c6bd13922f71df6c2146025b15ed757f118afc04.tar.gz
jgit-c6bd13922f71df6c2146025b15ed757f118afc04.zip
pgm: Handle exceptions in Status command
This avoids we show a stacktrace on the console by default when this type of exception is thrown during the run method is executed. Change-Id: I662a343fbb46c35090bd6f840e5a35a88036a65a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
index fb2fd7e235..039384db7d 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Status.java
@@ -54,6 +54,8 @@ import java.util.TreeSet;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.StatusCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.IndexDiff.StageState;
import org.eclipse.jgit.lib.Ref;
@@ -88,7 +90,7 @@ class Status extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
StatusCommand statusCommand = git.status();
if (filterPaths != null && filterPaths.size() > 0)
@@ -96,6 +98,8 @@ class Status extends TextBuiltin {
statusCommand.addPath(path);
org.eclipse.jgit.api.Status status = statusCommand.call();
printStatus(status);
+ } catch (GitAPIException | NoWorkTreeException | IOException e) {
+ throw die(e.getMessage(), e);
}
}