ebu_ecology_dev1/src/test/java/bokang/xiao/exception/ResponseException.java

69 lines
1.6 KiB
Java
Raw Normal View History

2023-07-05 23:30:08 +08:00
package bokang.xiao.exception;
import aiyh.utils.Util;
import org.apache.log4j.Logger;
/**
* @ClassName ResponseException
* @Author
* @Date 2023/7/5 16:03
* @Description <h1></h1>
**/
public class ResponseException extends RuntimeException{
private final Logger logger = Util.getLogger();
private final String msg;
private Throwable throwable;
private Integer code = -1;
public ResponseException(Throwable throwable) {
super(throwable);
this.msg = throwable.getMessage();
}
public ResponseException(String msg) {
super(msg);
this.msg = msg;
}
public ResponseException(String msg, String... obj) {
super(Util.logStr(msg, obj));
this.msg = Util.logStr(msg, obj);
}
public ResponseException(String msg, Integer code) {
super(msg);
this.code = code;
this.msg = msg;
}
public ResponseException(String msg, Integer code, Throwable throwable) {
super(msg, throwable);
this.code = code;
this.msg = msg;
}
public ResponseException(String msg, Throwable throwable) {
super(msg, throwable);
this.msg = msg;
this.throwable = throwable;
}
@Override
public void printStackTrace() {
logger.error("二开自定义异常:" + this.msg);
if (this.throwable != null) {
logger.error("异常信息: " + Util.getErrString(this.throwable));
}
}
public Integer getCode() {
return this.code;
}
@Override
public String getMessage() {
return this.msg;
}
}