1. 自定义统一接入异常 类
package com.psp.biz.pay.exception;
import com.psp.common.enums.RespCode;
import com.psp.common.exception.BizException;
/**
-
@Description 统一接入异常定义
-
@Author
-
@Date 2019/1/24
-
@Version 1.0
*/
public class BatchPayBizException extends BizException {private static final long serialVersionUID = 1L;
/**- 数据校验异常
*/
public static final BatchPayBizException LOGIN_STATUS_ERROR = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30023”, “登录失效,请重新登录”);
public static final BatchPayBizException DELETE_FILE_FAIL = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30024”, “文件删除失败”);
public static final BatchPayBizException FILE_NAME_ILLEGAL = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30025”, “文件名称非法”);
public static final BatchPayBizException IMPORT_TO_TMP_FAIL = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30026”, “导入临时表失败”);
public static final BatchPayBizException IMPORT_TO_DETAIL_FAIL = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30027”, “导入明细表失败”);
public static final BatchPayBizException STOKE_COUNT_DIFFERENT = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30028”, “总笔数与明细笔数不符”);
public static final BatchPayBizException RIGHT_DATA_NOT_EXSIT = new BatchPayBizException(RespCode.FAIL.getCode(), RespCode.FAIL.getMsg(), “30029”, “无正常数据”);
public BatchPayBizException(String code, String msg, String subCode, String msgFormat, Object… args) {
super(code, msg, subCode, msgFormat, args);
}public BatchPayBizException() {
super();
}public BatchPayBizException(String message) {
super(message);
}public BatchPayBizException(String message, Throwable cause) {
super(message, cause);
}public BatchPayBizException(Throwable cause) {
super(cause);
}
} - 数据校验异常
2. 自定义统一接入异常类 继承的类BizException
package com.psp.common.exception;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
-
@Description 异常定义基类
-
@Author
-
@Date 2018/7/3 10:32
-
@Version 1.0
*/
public class BizException extends RuntimeException {private static final long serialVersionUID = -5875371379845226068L;
private static final Logger log = LoggerFactory.getLogger(BizException.class);
protected String code;
protected String msg;
protected String subCode;
protected String subMsg;public String getMsg() {
return msg;
}public String getCode() {
return code;
}public void setMsg(String msg) {
this.msg = msg;
}public void setCode(String code) {
this.code = code;
}public String getSubCode() {
return subCode;
}public void setSubCode(String subCode) {
this.subCode = subCode;
}public String getSubMsg() {
return subMsg;
}public void setSubMsg(String subMsg) {
this.subMsg = subMsg;
}public BizException(String code, String msg, String subCode, String msgFormat, Object… args){
super(String.format(msgFormat,args));
this.code = code;
this.msg = msg;
this.subCode = subCode;
this.subMsg = String.format(msgFormat,args);
}public BizException() {
super();
}public BizException(String message) {
super(message);
}public BizException(String message, Throwable cause) {
super(message, cause);
}public BizException(Throwable cause) {
super(cause);
}public BizException print() {
log.error("==>BizException, code:" + this.code + “, msg:” + this.msg + “, subCode:” + this.subCode + “, subMsg:” + this.subMsg);
return this;
}
}