Help me guys. I have the following:
public class ParserException extends Exception {
ParserException(ErrorMessage errorCode) {
super(errorCode.getMessageText());
}
public enum ErrorMessage {
DIVISION_BY_ZERO("Деление на ноль");
private String messageText;
ErrorMessage(String text) {
this.messageText = text;
}
public String getMessageText() {
return messageText;
}
}
}
I want to pass my enum instance name in the way like this, without need to use quotes:
throw new ParserException(DIVISION_BY_ZERO);
I don't like an idea to include something in the class where I throw mentioned exception.
(Already have been suggested to use import static blah.blah.ParserException.ErrorMessage.*;
)
Is there any other gentle solution to deal with that kind of things? As you suspect I'll be pleased to solve it simply by adding a couple lines into my ParserException constructor.
Any good ideas? Thx.