Custom exceptions

A custom exception is a class that extends Exception (checked) or RuntimeException (unchecked) to express a specific business error, such as SoldeInsuffisantException. It carries a useful message and, if needed, the original cause (super(message, cause)).

Example

class SoldeInsuffisantException extends RuntimeException {
    SoldeInsuffisantException(String m) { super(m); }
}

Related concepts

The whole glossary