aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-01-21 23:52:27 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-01-21 23:52:27 +0100
commit9bf8a1bf14dc6334a6abd6d7cf980c50aa7eb111 (patch)
tree41efef1dab85762da295a210fc85963770d42e73 /org.eclipse.jgit.pgm
parent7d073c129c910f42aeabb43ce9b8ffa52a03acb5 (diff)
downloadjgit-9bf8a1bf14dc6334a6abd6d7cf980c50aa7eb111.tar.gz
jgit-9bf8a1bf14dc6334a6abd6d7cf980c50aa7eb111.zip
pgm: Handle IOException in UploadPack 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: Ife1d8e88387a32de63b0ef31f45499babdbdde3c 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/UploadPack.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
index 5d032d2084..53041d6a52 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/UploadPack.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.pgm;
import java.io.File;
+import java.io.IOException;
import java.text.MessageFormat;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
@@ -70,20 +71,20 @@ class UploadPack extends TextBuiltin {
/** {@inheritDoc} */
@Override
- protected void run() throws Exception {
- final org.eclipse.jgit.transport.UploadPack up;
-
+ protected void run() {
try {
FileKey key = FileKey.lenient(srcGitdir, FS.DETECTED);
db = key.open(true /* must exist */);
+ org.eclipse.jgit.transport.UploadPack up = new org.eclipse.jgit.transport.UploadPack(
+ db);
+ if (0 <= timeout)
+ up.setTimeout(timeout);
+ up.upload(ins, outs, errs);
} catch (RepositoryNotFoundException notFound) {
throw die(MessageFormat.format(CLIText.get().notAGitRepository,
srcGitdir.getPath()));
+ } catch (IOException e) {
+ throw die(e.getMessage(), e);
}
-
- up = new org.eclipse.jgit.transport.UploadPack(db);
- if (0 <= timeout)
- up.setTimeout(timeout);
- up.upload(ins, outs, errs);
}
}