pgm: Handle GitAPIException in Repo 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: I1a636478bfae8cc0635a3e57be252126e69c19cd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-01-21 23:21:26 +01:00
parent ec7ec69819
commit c03700dcb0
1 changed files with 11 additions and 6 deletions

View File

@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.pgm;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.gitrepo.RepoCommand;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@ -60,11 +61,15 @@ class Repo extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
new RepoCommand(db)
.setURI(uri)
.setPath(path)
.setGroups(groups)
.call();
protected void run() {
try {
new RepoCommand(db)
.setURI(uri)
.setPath(path)
.setGroups(groups)
.call();
} catch (GitAPIException e) {
throw die(e.getMessage(), e);
}
}
}