|
@@ -1,8 +1,15 @@
|
|
package com.qmth.teachcloud.common.enums;
|
|
package com.qmth.teachcloud.common.enums;
|
|
|
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
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 org.springframework.http.HttpStatus;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.StringJoiner;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @Description: 自定义异常消息枚举
|
|
* @Description: 自定义异常消息枚举
|
|
* @Param:
|
|
* @Param:
|
|
@@ -85,7 +92,7 @@ public enum ExceptionResultEnum {
|
|
|
|
|
|
SYNC_TASK_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000033, "同步任务不存在"),
|
|
SYNC_TASK_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000033, "同步任务不存在"),
|
|
|
|
|
|
- PAPER_STRUCT_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR,5100003,"试卷结构不一致"),
|
|
|
|
|
|
+ PAPER_STRUCT_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR, 5100003, "试卷结构不一致"),
|
|
|
|
|
|
/**
|
|
/**
|
|
* 401
|
|
* 401
|
|
@@ -145,7 +152,19 @@ public enum ExceptionResultEnum {
|
|
return new ApiException(status, code, message, message);
|
|
return new ApiException(status, code, message, message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(ExceptionResultEnum.class);
|
|
|
|
+
|
|
public ApiException exception(String 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);
|
|
return new ApiException(status, code, message, message);
|
|
}
|
|
}
|
|
}
|
|
}
|