// file: OpenListException // author: Robert M. Keller // purpose: Provide exception class for OpenList /** * An OpenListException is thrown when an attempt is made to do something * illegal with an open list, such as taking first or rest of an empty list. * The reason for the exception is encoded as the string argument to the * constructor. * Since this class extends RuntimeException rather than just Exception, * it is not necessary to declare every method that might conceivably * throw an OpenListException. */ class OpenListException extends RuntimeException { /** The reason the exception was thrown. */ private String reason; /** * Construct an OpenListException for a specified reason. * @param _reason the reason that the exception was thrown */ public OpenListException(String _reason) { reason = _reason; } /** * Return a printable version of this exception, which states the reason * the exception was thrown. * @return printable version of this exception */ public String toString() { return "OpenListException: " + reason; } }