]> source.dussan.org Git - jgit.git/commitdiff
pgm: Handle GitAPIException in Add command 98/135198/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 16 Jan 2019 17:02:07 +0000 (18:02 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 16 Jan 2019 23:43:39 +0000 (00:43 +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: I02940bdc1645c1d5e0abeeb4f1bafde1b8c54a1c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Add.java

index 08a9f48c04ec171b0676d1e67f597fb371d2c1da..9ecbbf13754cffbbd2e088e13bf55d0336582e6d 100644 (file)
@@ -48,6 +48,7 @@ import java.util.List;
 
 import org.eclipse.jgit.api.AddCommand;
 import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
 import org.kohsuke.args4j.Argument;
 import org.kohsuke.args4j.Option;
 
@@ -69,6 +70,8 @@ class Add extends TextBuiltin {
                        for (String p : filepatterns)
                                addCmd.addFilepattern(p);
                        addCmd.call();
+               } catch (GitAPIException e) {
+                       throw die(e.getMessage(), e);
                }
        }
 }