Browse Source

pgm: propagate generic exceptions when throwing Die exception

If a command is stopped by throwing a Die exception since a generic
exception was caught this exception contains additional information
which is not available in the error message. Hence chain it to the Die
exception in order to allow printing a complete stacktrace including
causes to the error stream of the JGit command line by adding option
--show-stack-trace, e.g.

$ jgit --show-stack-trace commit -m "test"

Change-Id: I7ad8c56b997ab60d2bd08f4e7b4d0b80c84021c3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.3
Matthias Sohn 6 years ago
parent
commit
159968abc4
  1. 4
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java
  2. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
  3. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java

4
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Archive.java

@ -97,10 +97,10 @@ class Archive extends TextBuiltin {
cmd.setFilename(output);
cmd.call();
} catch (GitAPIException e) {
throw die(e.getMessage());
throw die(e.getMessage(), e);
}
} catch (FileNotFoundException e) {
throw die(e.getMessage());
throw die(e.getMessage(), e);
} finally {
if (output != null && stream != null)
stream.close();

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java

@ -110,7 +110,7 @@ class Clone extends AbstractFetchCommand implements CloneCommand.Callback {
Constants.OS_USER_DIR), localName);
} catch (IllegalArgumentException e) {
throw die(MessageFormat.format(
CLIText.get().cannotGuessLocalNameFrom, sourceUri));
CLIText.get().cannotGuessLocalNameFrom, sourceUri), e);
}
} else
localNameF = new File(localName);

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/TextBuiltin.java

@ -196,7 +196,7 @@ public abstract class TextBuiltin {
try {
return Charset.forName(logOutputEncoding);
} catch (IllegalArgumentException e) {
throw die(CLIText.get().cannotCreateOutputStream);
throw die(CLIText.get().cannotCreateOutputStream, e);
}
}
}

Loading…
Cancel
Save