Provide a root cause for aborted commands
Change-Id: Iafaa03dbacbe7f1b2b074d3294db988b08fdb0d7 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
This commit is contained in:
parent
241b50be31
commit
4b7839cafd
|
@ -86,6 +86,21 @@ public Die(final String why, final Throwable cause) {
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
public Die(boolean aborted) {
|
public Die(boolean aborted) {
|
||||||
|
this(aborted, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new exception reflecting the fact that the command execution
|
||||||
|
* has been aborted before running.
|
||||||
|
*
|
||||||
|
* @param aborted
|
||||||
|
* boolean indicating the fact the execution has been aborted
|
||||||
|
* @param cause
|
||||||
|
* can be null
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
public Die(boolean aborted, final Throwable cause) {
|
||||||
|
super(cause != null ? cause.getMessage() : null, cause);
|
||||||
this.aborted = aborted;
|
this.aborted = aborted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ protected void parseArguments(final String[] args) throws IOException {
|
||||||
} catch (CmdLineException err) {
|
} catch (CmdLineException err) {
|
||||||
if (!help) {
|
if (!help) {
|
||||||
this.errw.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
|
this.errw.println(MessageFormat.format(CLIText.get().fatalError, err.getMessage()));
|
||||||
throw die(true);
|
throw die(true, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +324,19 @@ protected static Die die(boolean aborted) {
|
||||||
return new Die(aborted);
|
return new Die(aborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param aborted
|
||||||
|
* boolean indicating that the execution has been aborted before
|
||||||
|
* running
|
||||||
|
* @param cause
|
||||||
|
* why the command has failed.
|
||||||
|
* @return a runtime exception the caller is expected to throw
|
||||||
|
* @since 4.2
|
||||||
|
*/
|
||||||
|
protected static Die die(boolean aborted, final Throwable cause) {
|
||||||
|
return new Die(aborted, cause);
|
||||||
|
}
|
||||||
|
|
||||||
String abbreviateRef(String dst, boolean abbreviateRemote) {
|
String abbreviateRef(String dst, boolean abbreviateRemote) {
|
||||||
if (dst.startsWith(R_HEADS))
|
if (dst.startsWith(R_HEADS))
|
||||||
dst = dst.substring(R_HEADS.length());
|
dst = dst.substring(R_HEADS.length());
|
||||||
|
|
Loading…
Reference in New Issue