|
@@ -1,15 +1,8 @@
|
|
|
package com.qmth.teachcloud.common.enums;
|
|
|
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
-import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.StringJoiner;
|
|
|
-
|
|
|
/**
|
|
|
* @Description: 自定义异常消息枚举
|
|
|
* @Param:
|
|
@@ -145,46 +138,14 @@ public enum ExceptionResultEnum {
|
|
|
}
|
|
|
|
|
|
public ApiException exception() {
|
|
|
- try {
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- HttpServletRequest request = ServletUtil.getRequest();
|
|
|
- stringJoiner.add("[error path]:").add(request.getServletPath()).add("\r\n");
|
|
|
- stringJoiner.add("[status]:").add(String.valueOf(status.value())).add("\r\n");
|
|
|
- stringJoiner.add("[code]:").add(String.valueOf(code)).add("\r\n");
|
|
|
- stringJoiner.add("[message]:").add(message);
|
|
|
- log.error(SystemConstant.LOG_ERROR, stringJoiner.toString());
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
return new ApiException(status, code, message, message);
|
|
|
}
|
|
|
|
|
|
- private final static Logger log = LoggerFactory.getLogger(ExceptionResultEnum.class);
|
|
|
-
|
|
|
public ApiException exception(int code, String message) {
|
|
|
- try {
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- HttpServletRequest request = ServletUtil.getRequest();
|
|
|
- stringJoiner.add("[error path]:").add(request.getServletPath()).add("\r\n");
|
|
|
- stringJoiner.add("[status]:").add(String.valueOf(status.value())).add("\r\n");
|
|
|
- stringJoiner.add("[code]:").add(String.valueOf(code)).add("\r\n");
|
|
|
- stringJoiner.add("[message]:").add(message);
|
|
|
- log.error(SystemConstant.LOG_ERROR, stringJoiner.toString());
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
return new ApiException(status, code, message, message);
|
|
|
}
|
|
|
|
|
|
public ApiException exception(String message) {
|
|
|
- try {
|
|
|
- StringJoiner stringJoiner = new StringJoiner("");
|
|
|
- HttpServletRequest request = ServletUtil.getRequest();
|
|
|
- stringJoiner.add("[error path]:").add(request.getServletPath()).add("\r\n");
|
|
|
- stringJoiner.add("[status]:").add(String.valueOf(status.value())).add("\r\n");
|
|
|
- stringJoiner.add("[code]:").add(String.valueOf(code)).add("\r\n");
|
|
|
- stringJoiner.add("[message]:").add(message);
|
|
|
- log.error(SystemConstant.LOG_ERROR, stringJoiner.toString());
|
|
|
- } catch (Exception e) {
|
|
|
- }
|
|
|
return new ApiException(status, code, message, message);
|
|
|
}
|
|
|
}
|