]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle exceptions in Tag command 18/135518/1
authorMatthias Sohn <matthias.sohn@sap.com>
Mon, 21 Jan 2019 22:48:47 +0000 (23:48 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 21 Jan 2019 22:48:47 +0000 (23:48 +0100)
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: I16b528fad74d0c5346d054b3c29070331d60db7f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Tag.java

index 43c1f54ab5eccaa9f9a2df6770f35829eadf7142..1da4b1d26102e68d97f6566f38e634f466ad8a8c 100644 (file)
 
 package org.eclipse.jgit.pgm;
 
+import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.List;
 
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.ListTagCommand;
 import org.eclipse.jgit.api.TagCommand;
+import org.eclipse.jgit.api.errors.GitAPIException;
 import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.Ref;
@@ -82,7 +84,7 @@ class Tag extends TextBuiltin {
 
        /** {@inheritDoc} */
        @Override
-       protected void run() throws Exception {
+       protected void run() {
                try (Git git = new Git(db)) {
                        if (tagName != null) {
                                if (delete) {
@@ -115,6 +117,8 @@ class Tag extends TextBuiltin {
                                        outw.println(Repository.shortenRefName(ref.getName()));
                                }
                        }
+               } catch (GitAPIException | IOException e) {
+                       throw die(e.getMessage(), e);
                }
        }
 }