java define custom exception

Java
public class CustomException extends Exception { 
    public CustomException(String errorMessage) {
        super(errorMessage);
    }
}
Source

Also in Java: