diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-17 00:31:58 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-01-20 01:24:19 +0100 |
commit | 5482980e4f28472061b3d66be3e362f175d28dc3 (patch) | |
tree | 9b32b605c1d11605feed7a07323f33fffec4e7a6 | |
parent | fe52e2fb8ef447040014bbd9396bfe4a8e8315cf (diff) | |
download | jgit-5482980e4f28472061b3d66be3e362f175d28dc3.tar.gz jgit-5482980e4f28472061b3d66be3e362f175d28dc3.zip |
pgm: Handle exceptions in Clean 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: Ic06bf16c9bfc79753a9ec767f8030a12887df168
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java index 6ae078c953..db9e959259 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clean.java @@ -43,10 +43,13 @@ package org.eclipse.jgit.pgm; +import java.io.IOException; import java.text.MessageFormat; import java.util.Set; import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.pgm.internal.CLIText; import org.kohsuke.args4j.Option; @@ -64,7 +67,7 @@ class Clean extends TextBuiltin { /** {@inheritDoc} */ @Override - protected void run() throws Exception { + protected void run() { try (Git git = new Git(db)) { boolean requireForce = git.getRepository().getConfig() .getBoolean("clean", "requireForce", true); //$NON-NLS-1$ //$NON-NLS-2$ @@ -82,6 +85,8 @@ class Clean extends TextBuiltin { outw.println(MessageFormat.format(CLIText.get().removing, removedFile)); } + } catch (NoWorkTreeException | GitAPIException | IOException e) { + throw die(e.getMessage(), e); } } } |