public String toString() {
return JSONObject.toJSONString(this);
}
}
OK,到此关于返回码的东西以及大致完毕,我们现在开始写关于异常捕捉的。
首先写一个异常类继承RuntimeException, BizException.java:
/**
-
@Author:JCccc
-
@Description:
-
@Date: created in 15:18 2019/5/3
*/
public class BizException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
- 错误码
*/
protected String errorCode;
/**
- 错误信息
*/
protected String errorMsg;
public BizException() {
super();
}
public BizException(BaseErrorInfoInterface errorInfoInterface) {
super(errorInfoInterface.getResultCode());
this.errorCode = errorInfoInterface.getResultCode();
this.errorMsg = errorInfoInterface.getResultMsg();
}
public BizException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
super(errorInfoInterface.getResultCode(), cause);
this.errorCode = errorInfoInterface.getResultCode();
this.errorMsg = errorInfoInterface.getResultMsg();
}
public BizException(String errorMsg) {
super(errorMsg);
this.errorMsg = errorMsg;
}
public BizException(String errorCode, String errorMsg) {
super(errorCode);
this.errorCode = errorCode;
this.errorMsg = errorMsg;
}
public BizException(String errorCode, String errorMsg, Throwable cause) {
super(errorCode, cause);</