class that extends from exception code example
Example 1: java define custom exception
public class CustomException extends Exception {
public CustomException(String errorMessage) {
super(errorMessage);
}
}
Example 2: java exception override message
// Most exception classes provide a constructor requesting a String.
// Check the API of your superclass.
public class PersonalException extends RuntimeException{
public PersonalException() {
super("This is a message for you! Something went wrong...");
}
}