summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-01-20 01:45:38 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-20 01:45:38 +0100
commit11a907553629b87cb7affe59a7c9b2f4bda564f8 (patch)
tree311d1ec56232d408354f7ebc924709e5d97dc3ed /org.eclipse.jgit.pgm
parentd789c9adabbd6004e687c5d9b54d84376a8f557a (diff)
downloadjgit-11a907553629b87cb7affe59a7c9b2f4bda564f8.tar.gz
jgit-11a907553629b87cb7affe59a7c9b2f4bda564f8.zip
pgm: Handle exceptions in Describe 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: Ic5d9d94c4a451f300fb7ad3f71b3e22db9a2c181 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java
index f91474859d..705bcd7684 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Describe.java
@@ -42,12 +42,15 @@
*/
package org.eclipse.jgit.pgm;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jgit.api.DescribeCommand;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.RefNotFoundException;
+import org.eclipse.jgit.errors.InvalidPatternException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.pgm.internal.CLIText;
import org.kohsuke.args4j.Argument;
@@ -67,7 +70,7 @@ class Describe extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
+ protected void run() {
try (Git git = new Git(db)) {
DescribeCommand cmd = git.describe();
if (tree != null)
@@ -84,6 +87,8 @@ class Describe extends TextBuiltin {
throw die(CLIText.get().noNamesFound);
outw.println(result);
+ } catch (IOException | InvalidPatternException | GitAPIException e) {
+ throw die(e.getMessage(), e);
}
}
}