Avoid NPE in exception for bad version #2284

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2018-03-06 13:12:02 +11:00
parent c73ecae431
commit e2b9351662
2 changed files with 9 additions and 1 deletions

View File

@ -1275,7 +1275,9 @@ public class StartArgs
}
catch (Throwable x)
{
throw new UsageException(UsageException.ERR_BAD_ARG, x.getMessage());
UsageException ue = new UsageException(UsageException.ERR_BAD_ARG, x.getMessage()==null?x.toString():x.getMessage());
ue.initCause(x);
throw ue;
}
}
}

View File

@ -33,6 +33,12 @@ public class UsageException extends RuntimeException
public static final int ERR_UNKNOWN = -9;
private int exitCode;
public UsageException(int exitCode, String message)
{
super(message);
this.exitCode = exitCode;
}
public UsageException(int exitCode, String format, Object... objs)
{
super(String.format(format,objs));