Error codes within exception vs exceptions hierarchy
问题 Do you think it is ok to use error codes within exception to specify error type? Please take a look on this code: public class MyException extends Exception { public static final String ERROR_CODE_INVALID_NAME = ""; public static final String ERROR_CODE_INVALID_ID = ""; ... private String errorCode; public MyException(String message, String errorCode) { super(message); this.errorCode = errorCode; } public String getErrorCode() { return errorCode; } } I know that it is better to use enum