From fa3db15049aacf9e639b18e498511817cd4e131a Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 20 Jan 2019 21:53:30 +0100 Subject: [PATCH] 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 --- org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java index be8ad374d..faa0f51d7 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java @@ -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); } }