/** * Exception thrown if error occurs while parsing a users transcript. */ public class TranscriptException extends Exception { public static final int ERROR_SHUTDOWN = 0; public static final int ERROR_CONTINUE = 1; private int errorCode; /** * Constructs a TranscriptException with error code ERROR_SHUTDOWN. * @param msg the exception message. */ public TranscriptException(String msg) { super(msg); errorCode = ERROR_SHUTDOWN; } /** * Constructs a TranscriptException with a user supplied error code. * @param msg the exception message. * @param code the error code (ERROR_SHUTDOWN or ERROR_CONTINUE). */ public TranscriptException(String msg, int code) { super(msg); errorCode = code; } /** * Constructs a TranscriptException out of a throwable object. If it * is an instance of TranscriptException, the error code is extracted. * @param throwable A throwable object to construct the exception with. */ public TranscriptException(Throwable throwable) { super(throwable); if(throwable instanceof TranscriptException) errorCode = ((TranscriptException)throwable).getErrorCode(); else errorCode = ERROR_SHUTDOWN; } /** * Returns the error code of the exception. * @return The error code. */ public int getErrorCode() { return errorCode; } }