|
@@ -11,6 +11,10 @@ import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
|
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
|
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
|
|
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
+import jakarta.validation.ConstraintViolation;
|
|
|
+import jakarta.validation.ConstraintViolationException;
|
|
|
+import jakarta.validation.ValidationException;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
@@ -26,13 +30,8 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
|
|
import org.springframework.web.servlet.NoHandlerFoundException;
|
|
|
|
|
|
-import jakarta.servlet.http.HttpServletRequest;
|
|
|
-import jakarta.validation.ConstraintViolation;
|
|
|
-import jakarta.validation.ConstraintViolationException;
|
|
|
-import jakarta.validation.ValidationException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.*;
|
|
|
|
|
@@ -181,14 +180,6 @@ public class GlobalExceptionHandler {
|
|
|
return CommonResult.error(METHOD_NOT_ALLOWED.getCode(), String.format("请求方法不正确:%s", ex.getMessage()));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 处理 Resilience4j 限流抛出的异常
|
|
|
- */
|
|
|
- public CommonResult<?> requestNotPermittedExceptionHandler(HttpServletRequest req, Throwable ex) {
|
|
|
- log.warn("[requestNotPermittedExceptionHandler][url({}) 访问过于频繁]", req.getRequestURL(), ex);
|
|
|
- return CommonResult.error(TOO_MANY_REQUESTS);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 处理 Spring Security 权限不足的异常
|
|
|
*
|
|
@@ -223,12 +214,7 @@ public class GlobalExceptionHandler {
|
|
|
return tableNotExistsResult;
|
|
|
}
|
|
|
|
|
|
- // 情况二:部分特殊的库的处理
|
|
|
- if (Objects.equals("io.github.resilience4j.ratelimiter.RequestNotPermitted", ex.getClass().getName())) {
|
|
|
- return requestNotPermittedExceptionHandler(req, ex);
|
|
|
- }
|
|
|
-
|
|
|
- // 情况三:处理异常
|
|
|
+ // 情况二:处理异常
|
|
|
log.error("[defaultExceptionHandler]", ex);
|
|
|
// 插入异常日志
|
|
|
this.createExceptionLog(req, ex);
|