Browse Source

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>
stable-5.4
Matthias Sohn 6 years ago
parent
commit
fa3db15049
  1. 5
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java

5
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Push.java

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

Loading…
Cancel
Save