wangliang 4 anos atrás
pai
commit
09ef08ba07

+ 3 - 6
themis-common/src/main/java/com/qmth/themis/common/exception/GlobalDefultExceptionHandler.java

@@ -35,22 +35,19 @@ public class GlobalDefultExceptionHandler {
     @ExceptionHandler(Exception.class)
     @ResponseBody
     public <T> Result defultExcepitonHandler(Exception e, HttpServletResponse response) {
-        log.error("请求报错", e);
         if (e instanceof BusinessException) {
             BusinessException businessException = (BusinessException) e;
             response.setStatus(businessException.getStatusCode());
-            log.error("statusCode:{}\ncode:{}\nmessage:{}\nexception:{}", businessException.getStatusCode(), businessException.getCode(), e.getMessage(), e.getStackTrace());
             return ResultUtil.error(businessException.getCode(), businessException.getMessage());
         } else if (e instanceof IllegalArgumentException) {
             response.setStatus(ExceptionResultEnum.EXCEPTION_ERROR.getStatusCode());
-            log.error("statusCode:{}\ncode:{}\nmessage:{}\nexception:{}", ExceptionResultEnum.EXCEPTION_ERROR.getStatusCode(), ExceptionResultEnum.EXCEPTION_ERROR.getCode(), e.getMessage(), e.getStackTrace());
             if (e.getMessage().contains("No enum constant com.qmth.themis.common.enums.Platform")) {
                 return ResultUtil.error(ExceptionResultEnum.EXCEPTION_ERROR.getCode(), "暂不支持此平台");
             }
         }
         response.setStatus(ExceptionResultEnum.EXCEPTION_ERROR.getStatusCode());
-        log.error("statusCode:{}\ncode:{}\nmessage:{}\nexception:{}", ExceptionResultEnum.EXCEPTION_ERROR.getStatusCode(), ExceptionResultEnum.EXCEPTION_ERROR.getCode(), e.getMessage(), e.getStackTrace());
         //Exception错误
+        log.error("Exception 请求出错", e);
         return ResultUtil.error(ExceptionResultEnum.EXCEPTION_ERROR.getCode(), e.getMessage());
     }
 
@@ -66,7 +63,7 @@ public class GlobalDefultExceptionHandler {
     @ResponseBody
     public <T> Result sqlExceptionHandler(SQLException e, HttpServletResponse response) {
         response.setStatus(ExceptionResultEnum.SQL_ERROR.getStatusCode());
-        log.error("statusCode:{}\ncode:{}\nmessage:{}\nexception:{}", ExceptionResultEnum.SQL_ERROR.getStatusCode(), ExceptionResultEnum.SQL_ERROR.getCode(), e.getMessage(), e.getStackTrace());
+        log.error("SQLException 请求出错", e);
         return ResultUtil.error(ExceptionResultEnum.SQL_ERROR.getCode(), e.getMessage());
     }
 
@@ -82,7 +79,7 @@ public class GlobalDefultExceptionHandler {
     @ResponseBody
     public <T> Result invocationTargetExceptionHandler(InvocationTargetException e, HttpServletResponse response) {
         response.setStatus(ExceptionResultEnum.INVOCATIONTARGET_ERROR.getStatusCode());
-        log.error("statusCode:{}\ncode:{}\nmessage:{}\nexception:{}", ExceptionResultEnum.INVOCATIONTARGET_ERROR.getStatusCode(), ExceptionResultEnum.INVOCATIONTARGET_ERROR.getCode(), e.getMessage(), e.getStackTrace());
+        log.error("invocationTargetExceptionHandler 请求出错", e);
         return ResultUtil.error(ExceptionResultEnum.INVOCATIONTARGET_ERROR.getCode(), ExceptionResultEnum.INVOCATIONTARGET_ERROR.name() + e.getTargetException());
     }
 }