Browse Source

err handler 2

master
gsd 11 months ago
parent
commit
38bc890e12
  1. 12
      src/main/java/app/exceptions/RestResponseStatusExceptionResolver.java

12
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;
}
}

Loading…
Cancel
Save