public class LuckyException extends RuntimeException
try{
if( a != null){
a.doSomething();
}
}catch(NullPointerException npe){
throw new LuckyException("I found a null pointer!");
}
Of course the system will never require you to catch NullPOinterException as
it derives from RuntimeException, but I couldn't come with a better example.Constructor and Description |
---|
LuckyException()
Default constructor, creates a new execption with the default message
|
LuckyException(String message)
Creates a new exception with the provided message prepended to the default
one on a separate line.
|
LuckyException(String message,
Throwable cause) |
LuckyException(Throwable cause) |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public LuckyException()
public LuckyException(String message)
message
- the uses messagepublic LuckyException(String message, Throwable cause)
public LuckyException(Throwable cause)