Sfoglia il codice sorgente

统一异常处理优化

叶君翔 3 anni fa
parent
commit
3e2f2a98dc

+ 5 - 0
lb-framework/src/main/java/com/ydd/framework/web/exception/GlobalExceptionHandler.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
 import org.springframework.web.servlet.NoHandlerFoundException;
 
 import javax.validation.ConstraintViolationException;
+import java.io.IOException;
 
 /**
  * 全局异常处理器
@@ -85,6 +86,10 @@ public class GlobalExceptionHandler {
     @ExceptionHandler(Exception.class)
     public Result handleException(Exception e) {
         log.error(e.getMessage(), e);
+        if (e instanceof IOException) {
+            log.error("操作异常: IO异常, 暂时不处理; 异常信息: {}", e.getMessage());
+            return Result.error(501, "操作异常: IO异常, 暂时不处理!");
+        }
         return Result.error();
     }