Java Exception Message 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?
Don't throw raw Exceptions, use always a subclass (as explained by MrLore). If you are throwing raw exceptions you also have to catch them, which might mask other exception or runtime exceptions. You would add a instanceof to any of your catch blocks.