From 38bc890e129fe88e3a0f83fe2ead90e3863ebc88 Mon Sep 17 00:00:00 2001 From: gsd Date: Wed, 24 Apr 2024 23:14:12 +0300 Subject: [PATCH] err handler 2 --- .../RestResponseStatusExceptionResolver.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/app/exceptions/RestResponseStatusExceptionResolver.java b/src/main/java/app/exceptions/RestResponseStatusExceptionResolver.java index 75ca727..f235b8d 100644 --- a/src/main/java/app/exceptions/RestResponseStatusExceptionResolver.java +++ b/src/main/java/app/exceptions/RestResponseStatusExceptionResolver.java @@ -4,14 +4,15 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.Ordered; import org.springframework.stereotype.Component; import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver; +import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver; import java.util.UUID; @Component -public class RestResponseStatusExceptionResolver extends AbstractHandlerExceptionResolver { +public class RestResponseStatusExceptionResolver extends DefaultHandlerExceptionResolver { private final Logger logger = LoggerFactory.getLogger(getClass()); @Override @@ -20,6 +21,11 @@ public class RestResponseStatusExceptionResolver extends AbstractHandlerExceptio logger.error("[{}] Found error in request {} with path {}", uuid, request.getMethod(), request.getRequestURI()); logger.error("["+uuid+"]", ex); logger.error("[{}] Request ended with code: {}", uuid, response.getStatus()); - return null; + return super.doResolveException(request, response, handler, ex); + } + + @Override + public int getOrder() { + return Ordered.HIGHEST_PRECEDENCE; } }