I have a few custom exception classes that I created simply for the sake of having my own exception message:public class DivideByZeroException extends Exception {      @Override   public String toString()   {       return ERROR: Expression cannot divide by 0;   }}I realize that this can be done by throwing an exception like: throw new Exception(ERROR: Expression cannot divide by 0);but this contains a prefix of java.lang.Exception: in the string.I think it's a bit ugly to remove the unwanted prefix from the string, but creating a class just for the exception message seems a bit excessive to me. Is there a different way to do this?
Java Exception Message
java;exception
If you want all your exceptions to follow this style, then you could have one parent Exception class, then make your application exceptions extend it, like so:class MyException extends Exception{    MyException(String message)    {        super(message);    }    @Override    public String toString()    {        return ERROR:  + this.getMessage();    }}class DivideByZeroException extends MyException{    DivideByZeroException()    {        super(Expression cannot divide by 0);    }}This way, you don't have to override toString() every time, and you also don't have to put ERROR into the actual text of the exception.