package bokang.xiao.exception; import aiyh.utils.Util; import org.apache.log4j.Logger; /** * @ClassName ResponseException * @Author 肖博亢 * @Date 2023/7/5 16:03 * @Description

**/ 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; } }