Browse Source

pgm: Handle exceptions in Show 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: I1c6cc5ecdc44b81e5f3f9b7dc64c3653de5475ba
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.4
Matthias Sohn 6 years ago
parent
commit
e5511f2fbb
  1. 7
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java

7
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Show.java

@ -59,6 +59,7 @@ import org.eclipse.jgit.diff.RenameDetector;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.RevisionSyntaxException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
@ -175,7 +176,7 @@ class Show extends TextBuiltin {
/** {@inheritDoc} */
@SuppressWarnings("boxing")
@Override
protected void run() throws Exception {
protected void run() {
diffFmt.setRepository(db);
try {
diffFmt.setPathFilter(pathFilter);
@ -224,6 +225,8 @@ class Show extends TextBuiltin {
obj.getType()));
}
}
} catch (RevisionSyntaxException | IOException e) {
throw die(e.getMessage(), e);
} finally {
diffFmt.close();
}
@ -273,7 +276,7 @@ class Show extends TextBuiltin {
}
}
private void show(RevWalk rw, RevCommit c) throws Exception {
private void show(RevWalk rw, RevCommit c) throws IOException {
char[] outbuffer = new char[Constants.OBJECT_ID_LENGTH * 2];
outw.print(CLIText.get().commitLabel);

Loading…
Cancel
Save