diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-21 23:23:36 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-21 23:23:36 +0100 |
commit | 5c05b9f38c89b8d8c4dc8181e918c57589c96921 (patch) | |
tree | 9fd82e0cfc1fa3be368a891a99ef00f2c259a329 /org.eclipse.jgit.pgm | |
parent | c03700dcb044c2a58b1ca9fcec387253fe0aabd7 (diff) | |
download | jgit-5c05b9f38c89b8d8c4dc8181e918c57589c96921.tar.gz jgit-5c05b9f38c89b8d8c4dc8181e918c57589c96921.zip |
pgm: Handle GitAPIException in Reset 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: I70dce366081cd1fc4539cf195d6310fef1080eb3
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/Reset.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java index f84c848063..7f0396918c 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Reset.java @@ -49,6 +49,7 @@ import java.util.List; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ResetCommand; import org.eclipse.jgit.api.ResetCommand.ResetType; +import org.eclipse.jgit.api.errors.GitAPIException; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.kohsuke.args4j.spi.RestOfArgumentsHandler; @@ -74,7 +75,7 @@ class Reset extends TextBuiltin { /** {@inheritDoc} */ @Override - protected void run() throws Exception { + protected void run() { try (Git git = new Git(db)) { ResetCommand command = git.reset(); command.setRef(commit); @@ -94,6 +95,8 @@ class Reset extends TextBuiltin { command.setMode(mode); } command.call(); + } catch (GitAPIException e) { + throw die(e.getMessage(), e); } } |