want to abort w/o message, and to always stuff in a stack tracetags/V_1_1_b2
*/ | */ | ||||
public class AbortException extends RuntimeException { // XXX move porters out, handle proxy better | public class AbortException extends RuntimeException { // XXX move porters out, handle proxy better | ||||
private boolean isSilent = false; | |||||
/** used when message text is null */ | /** used when message text is null */ | ||||
public static final String NO_MESSAGE_TEXT | public static final String NO_MESSAGE_TEXT | ||||
= "AbortException (no message)"; | = "AbortException (no message)"; | ||||
private static final ArrayList porters = new ArrayList(); | private static final ArrayList porters = new ArrayList(); | ||||
/** | |||||
* A client may throw this rather than constructing their own | |||||
* if stack trace or message is not needed when caught. | |||||
*/ | |||||
public static final AbortException ABORT | |||||
= new AbortException("ABORT"); | |||||
/** | /** | ||||
* Get a porter exception from the pool. | * Get a porter exception from the pool. | ||||
result = (AbortException) porters.get(0); | result = (AbortException) porters.get(0); | ||||
} else { | } else { | ||||
result = new AbortException(); | result = new AbortException(); | ||||
result.setIsSilent(false); | |||||
} | } | ||||
} | } | ||||
result.setIMessage(message); | result.setIMessage(message); | ||||
/** abort with default String message */ | /** abort with default String message */ | ||||
public AbortException() { | public AbortException() { | ||||
this((String) null); | |||||
this("ABORT"); | |||||
isSilent = true; | |||||
} | } | ||||
/** abort with message */ | /** abort with message */ | ||||
} | } | ||||
} | } | ||||
public boolean isSilent() { | |||||
return isSilent; | |||||
} | |||||
public void setIsSilent(boolean isSilent) { | |||||
this.isSilent = isSilent; | |||||
} | |||||
} | } |
// -- throwable | // -- throwable | ||||
kind = IMessage.FAIL; | kind = IMessage.FAIL; | ||||
thrown = AbortException.ABORT; | |||||
thrown = new AbortException(); | |||||
input = null; | input = null; | ||||
roundTrip(input, kind, thrown, sl, descriptor, exClass); | roundTrip(input, kind, thrown, sl, descriptor, exClass); | ||||
&& buildManager.batchBuild(config, counter) | && buildManager.batchBuild(config, counter) | ||||
&& !counter.hasErrors()); | && !counter.hasErrors()); | ||||
} catch (AbortException ae) { | } catch (AbortException ae) { | ||||
if (AbortException.ABORT.equals(ae)) { | |||||
if (ae.isSilent()) { | |||||
throw ae; | throw ae; | ||||
} else { | } else { | ||||
MessageUtil.abort(handler, ABORT_MESSAGE, ae); | MessageUtil.abort(handler, ABORT_MESSAGE, ae); | ||||
if (null != message) { | if (null != message) { | ||||
IMessage.Kind kind = inferKind(message); | IMessage.Kind kind = inferKind(message); | ||||
handler.handleMessage(new Message(message, kind, null, null)); | handler.handleMessage(new Message(message, kind, null, null)); | ||||
throw AbortException.ABORT; // XXX tangled - assumes handler prints? | |||||
throw new AbortException(); // XXX tangled - assumes handler prints? | |||||
} | } | ||||
return config; | return config; | ||||
} | } |
} | } | ||||
} | } | ||||
} catch (AbortException ae) { | } catch (AbortException ae) { | ||||
if (AbortException.ABORT.equals(ae)) { | |||||
if (ae.isSilent()) { | |||||
quit(); | quit(); | ||||
} else { | } else { | ||||
IMessage message = ae.getIMessage(); | IMessage message = ae.getIMessage(); |