소스 검색

代码优化

wangliang 2 년 전
부모
커밋
20b249a8ab
1개의 변경된 파일22개의 추가작업 그리고 2개의 파일을 삭제
  1. 22 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ExceptionResultEnum.java

+ 22 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/ExceptionResultEnum.java

@@ -145,15 +145,35 @@ 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);
     }
 
-    private final static Logger log = LoggerFactory.getLogger(ExceptionResultEnum.class);
-
     public ApiException exception(String message) {
         try {
             StringJoiner stringJoiner = new StringJoiner("");