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>
This commit is contained in:
parent
d4d9625d4b
commit
159968abc4
|
@ -97,10 +97,10 @@ protected void run() throws Exception {
|
|||
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();
|
||||
|
|
|
@ -110,7 +110,7 @@ protected void run() throws Exception {
|
|||
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);
|
||||
|
|
|
@ -196,7 +196,7 @@ private Charset getLogOutputEncodingCharset(Repository repository) {
|
|||
try {
|
||||
return Charset.forName(logOutputEncoding);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw die(CLIText.get().cannotCreateOutputStream);
|
||||
throw die(CLIText.get().cannotCreateOutputStream, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue