lyhzzz 2 years ago
parent
commit
776a75bd67

+ 3 - 12
src/main/java/com/fdkankan/sale/exception/GlobalExceptionHandler.java

@@ -23,6 +23,9 @@ public class GlobalExceptionHandler {
     @ExceptionHandler(value = Exception.class)
     public ResultData exceptionHandler(Exception e) throws Exception {
         log.error("服务错误:", e);
+        if(e.getCause().getMessage().contains("out of range of")){
+            return ResultData.error(ResultCode.DATA_TOO_LONG);
+        }
         return ResultData.error( 500, e.getCause().getMessage());
     }
 
@@ -50,16 +53,4 @@ public class GlobalExceptionHandler {
         }
         return ResultData.error( 500, e.getCause().getMessage());
     }
-    /**
-     * 处理业务异常
-     */
-    @ResponseBody
-    @ExceptionHandler(value = InputCoercionException.class)
-    public ResultData InputCoercionExceptionHandler(InputCoercionException e) {
-        log.error("数字大小:", e);
-        if(e.getCause().getMessage().contains("out of range of")){
-            return ResultData.error(ResultCode.DATA_TOO_LONG);
-        }
-        return ResultData.error( 500, e.getCause().getMessage());
-    }
 }