pgm: Handle exceptions in Push 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: I7a5dc6b1ebaad6f7b8baa35ce68760b79bab8acd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-01-20 21:53:30 +01:00
parent c821054316
commit fa3db15049
1 changed files with 4 additions and 1 deletions

View File

@ -53,6 +53,7 @@
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.PushCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ObjectReader;
@ -115,7 +116,7 @@ void nothin(@SuppressWarnings("unused") final boolean ignored) {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
protected void run() {
try (Git git = new Git(db)) {
PushCommand push = git.push();
push.setDryRun(dryRun);
@ -140,6 +141,8 @@ protected void run() throws Exception {
printPushResult(reader, result.getURI(), result);
}
}
} catch (GitAPIException | IOException e) {
throw die(e.getMessage(), e);
}
}