Files
springboot-common/src/main/java/cn/zhangdeman/CustomException.java

31 lines
863 B
Java

package cn.zhangdeman;
import lombok.Getter;
import lombok.Setter;
// 自定义异常
@Getter
@Setter
public class CustomException extends RuntimeException {
private final String code; // 错误码
private final String message; // 异常信息
private final Object data; // 异常数据
public CustomException(String message) {
super(message);
this.code = "-1";
this.data = null;
this.message = message;
}
// 根据code与
public CustomException(String code, Object data) {
this.code = code;
this.message = HashMapCache.getHashMapCache().getCodeMessage(code); // 根据code初始化Message
this.data = data;
}
public CustomException(String code, String message, Object data) {
this.code = code;
this.message = message;
this.data = data;
}
}