public class MyException extends RuntimeException {
private String errorCode;
public MyException(String message) {
super(message);
}
public MyException(String errorCode,String message) {
super(message);
this.errorCode = errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorCode() {
return errorCode;
}
}
public static void main(String[] args) {
try {
if (true) {
throw new MyException("9999","业务异常出现了");
}
} catch (MyException e) {
System.out.println(e.getErrorCode()+e.getMessage());
}
}