In theory you could subclass
Throwable
directly, but that’s considered
rude. You normally subclass Exception
(if you want
a checked
exception) or RuntimeException
(if you want an
unchecked exception). Checked
exceptions are those that an application developer is required to
catch, or “throw away” by listing them in the
throws
clause of the invoking method.
When subclassing either of these, it is customary to provide at least a no-argument and a one-string argument constructor:
/** A ChessMoveException is thrown when the user makes an illegal move. */ public class ChessMoveException extends RuntimeException { public ChessMoveException ( ) { super( ); } public ChessMoveException (String msg) { super(msg); } }
3.145.39.60