pgm: Handle IOException in Version 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: I37e6e3aaba411858042afac02098ce9eaa06f258
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2019-01-21 23:54:28 +01:00
parent e74592605e
commit 7383d34737
1 changed files with 7 additions and 2 deletions

View File

@ -57,7 +57,7 @@
class Version extends TextBuiltin {
/** {@inheritDoc} */
@Override
protected void run() throws Exception {
protected void run() {
// read the Implementation-Version from Manifest
String version = getImplementationVersion();
@ -71,7 +71,12 @@ protected void run() throws Exception {
if (version == null)
throw die(CLIText.get().cannotReadPackageInformation);
outw.println(MessageFormat.format(CLIText.get().jgitVersion, version));
try {
outw.println(
MessageFormat.format(CLIText.get().jgitVersion, version));
} catch (IOException e) {
throw die(e.getMessage(), e);
}
}
/** {@inheritDoc} */