|
@@ -7,6 +7,8 @@ package com.aizuda.boot.config;
|
|
|
|
|
|
import com.aizuda.bpm.engine.exception.FlowLongException;
|
|
|
import com.aizuda.core.api.ApiResult;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
@@ -18,6 +20,7 @@ import java.io.IOException;
|
|
|
/**
|
|
|
* 自定义异常统一提示
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestControllerAdvice
|
|
|
public class BootException {
|
|
|
|
|
@@ -31,11 +34,18 @@ public class BootException {
|
|
|
return ApiResult.failed(e.getMessage());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * IO 异常处理
|
|
|
+ */
|
|
|
@ExceptionHandler(IOException.class)
|
|
|
- @ResponseStatus(HttpStatus.OK)
|
|
|
+ @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
|
@ResponseBody
|
|
|
- public ApiResult<String> handleIOException(IOException e) {
|
|
|
+ public void handleIOException(IOException e, HttpServletRequest request) {
|
|
|
// 捕获 IO 异常,例如 sse 连接断开
|
|
|
- return ApiResult.failed(e.getMessage());
|
|
|
+ String uri = request.getRequestURI();
|
|
|
+ if (!uri.contains("/sse")) {
|
|
|
+ // 记录非 sse 请求的异常日志
|
|
|
+ log.error("请求地址 {} 连接中断 {}", uri, e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|