diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-21 23:39:04 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-21 23:39:04 +0100 |
commit | ed0d6e69f990aa51d874760300b3536ace2dc697 (patch) | |
tree | 80e94b5d622b8d238d6841926f74d1b495ba0aad | |
parent | 795c265c11bcab6b54772194fae6cb91bc66ac00 (diff) | |
download | jgit-ed0d6e69f990aa51d874760300b3536ace2dc697.tar.gz jgit-ed0d6e69f990aa51d874760300b3536ace2dc697.zip |
pgm: Handle GitAPIException in Rm 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: I55c15a35369e790a3ca946d6db0097a57ac6fae5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java index f59161039e..aa0bb4a775 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Rm.java @@ -49,6 +49,7 @@ import java.util.List; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.RmCommand; +import org.eclipse.jgit.api.errors.GitAPIException; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; import org.kohsuke.args4j.spi.StopOptionHandler; @@ -61,12 +62,14 @@ class Rm extends TextBuiltin { /** {@inheritDoc} */ @Override - protected void run() throws Exception { + protected void run() { try (Git git = new Git(db)) { RmCommand command = git.rm(); for (String p : paths) command.addFilepattern(p); command.call(); + } catch (GitAPIException e) { + throw die(e.getMessage(), e); } } } |