package exception; import api.StatusCode; public class BizException extends RuntimeException { private static final long serialVersionUID = 2466145171145432619L; private StatusCode codeEnum; private Integer code = 500; public BizException(String message) { super(message); } public BizException(String message, Integer code) { super(message); this.code = code; } public StatusCode getCodeEnum() { return codeEnum; } public Integer getCode() { return this.code; } public BizException(StatusCode codeEnum) { super(codeEnum.getMessage()); this.codeEnum = codeEnum; this.code = codeEnum.getCode(); } /** * 重写fillInStackTrace 业务异常不需要堆栈信息,提高效率. */ @Override public Throwable fillInStackTrace() { return this; } }