Skip to content

Commit 6ee5440

Browse files
committed
fix:【framework 全局】GlobalExceptionHandler 处理 guava UncheckedExecutionException 异常,https://t.zsxq.com/UszdH
1 parent ef26a14 commit 6ee5440

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
1818
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
1919
import com.google.common.util.concurrent.UncheckedExecutionException;
20-
import jakarta.servlet.http.HttpServletRequest;
21-
import jakarta.validation.ConstraintViolation;
22-
import jakarta.validation.ConstraintViolationException;
23-
import jakarta.validation.ValidationException;
2420
import lombok.AllArgsConstructor;
2521
import lombok.extern.slf4j.Slf4j;
2622
import org.springframework.http.converter.HttpMessageNotReadableException;
@@ -37,8 +33,11 @@
3733
import org.springframework.web.bind.annotation.RestControllerAdvice;
3834
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
3935
import org.springframework.web.servlet.NoHandlerFoundException;
40-
import org.springframework.web.servlet.resource.NoResourceFoundException;
4136

37+
import javax.servlet.http.HttpServletRequest;
38+
import javax.validation.ConstraintViolation;
39+
import javax.validation.ConstraintViolationException;
40+
import javax.validation.ValidationException;
4241
import java.time.LocalDateTime;
4342
import java.util.List;
4443
import java.util.Map;
@@ -96,9 +95,6 @@ public CommonResult<?> allExceptionHandler(HttpServletRequest request, Throwable
9695
if (ex instanceof NoHandlerFoundException) {
9796
return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex);
9897
}
99-
if (ex instanceof NoResourceFoundException) {
100-
return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex);
101-
}
10298
if (ex instanceof HttpRequestMethodNotSupportedException) {
10399
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
104100
}
@@ -226,15 +222,6 @@ public CommonResult<?> noHandlerFoundExceptionHandler(NoHandlerFoundException ex
226222
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
227223
}
228224

229-
/**
230-
* 处理 SpringMVC 请求地址不存在
231-
*/
232-
@ExceptionHandler(NoResourceFoundException.class)
233-
private CommonResult<?> noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) {
234-
log.warn("[noResourceFoundExceptionHandler]", ex);
235-
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath()));
236-
}
237-
238225
/**
239226
* 处理 SpringMVC 请求方法不正确
240227
*

0 commit comments

Comments
 (0)