Przeglądaj źródła

:zap: 打印错误信息

Aron 6 lat temu
rodzic
commit
b427cda145

+ 5 - 6
src/main/java/com/ifast/common/exception/handler/ApplicationExceptionHandler.java

@@ -50,7 +50,7 @@ public class ApplicationExceptionHandler {
      */
     @ExceptionHandler(IFastException.class)
     public Object handleIFastException(IFastException e) {
-        e.getMessage();
+        e.printStackTrace();
 
         if(!HttpContextUtils.isAjax()){
             ModelAndView mv = new ModelAndView();
@@ -67,7 +67,6 @@ public class ApplicationExceptionHandler {
             return Result.build(code, EnumErrorCode.getMsgByCode(code));
         } catch (NumberFormatException e1) {
             log.warn("错误码使用错误,异常内容请抛出EnumErrorCode类的枚举值");
-            e1.printStackTrace();
             return Result.build(EnumErrorCode.unknowFail.getCode(), EnumErrorCode.unknowFail.getMsg());
         }
     }
@@ -75,19 +74,19 @@ public class ApplicationExceptionHandler {
 
     @ExceptionHandler(DuplicateKeyException.class)
     public Result<String> handleDuplicateKeyException(DuplicateKeyException e) {
-        log.error(e.getMessage());
+        e.printStackTrace();
         return Result.build(EnumErrorCode.duplicateKeyExist.getCode(), EnumErrorCode.duplicateKeyExist.getMsg());
     }
 
     @ExceptionHandler(NoHandlerFoundException.class)
     public Result<String> noHandlerFoundException(NoHandlerFoundException e) {
-        log.error(e.getMessage());
+        e.printStackTrace();
         return Result.build(EnumErrorCode.pageNotFound.getCode(), EnumErrorCode.pageNotFound.getMsg());
     }
 
     @ExceptionHandler(ShiroException.class)
     public Result<String> handleAuthorizationException(ShiroException e) {
-        log.error(e.getMessage());
+        e.printStackTrace();
         if(e instanceof IncorrectCredentialsException) {
         	return Result.build(EnumErrorCode.apiAuthorizationFailed.getCode(), EnumErrorCode.apiAuthorizationFailed.getMsg());
         }else if(e instanceof ExpiredCredentialsException) {
@@ -98,7 +97,7 @@ public class ApplicationExceptionHandler {
 
     @ExceptionHandler(Exception.class)
     public Object handleException(Exception e) {
-        log.error(e.getMessage());
+        e.printStackTrace();
         if(!HttpContextUtils.isAjax()){
             ModelAndView mv = new ModelAndView();
             mv.setViewName(ERROR_DEFAULT_PAGE);