定义异常类
public class BusinessException extends Exception {
private static final long serialVersionUID = -928281303665542095L;
private String errCode;
private String errMsg;
private String message;
public String getErrCode() {
return errCode;
}
public void setErrCode(String errCode) {
this.errCode = errCode;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public void setMessage(String message) {
this.message = message;
}
public BusinessException() {
super();
}
public BusinessException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public BusinessException(String message, Throwable cause) {
super(message, cause);
}
public BusinessException(String message) {
super(message);
setMessage(message);
}
public BusinessException(Throwable cause) {
super(cause);
}
@Override
public String getMessage() {
return message;
}
@Override
public String toString() {
return BusinessException.class.getCanonicalName() + message;
}
}
项目中如何自定义异常类
最新推荐文章于 2024-09-21 21:33:45 发布