1 changed files with 25 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||||
|
package app.exceptions; |
||||
|
|
||||
|
import jakarta.servlet.http.HttpServletRequest; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.servlet.ModelAndView; |
||||
|
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver; |
||||
|
|
||||
|
import java.util.UUID; |
||||
|
|
||||
|
@Component |
||||
|
public class RestResponseStatusExceptionResolver extends AbstractHandlerExceptionResolver { |
||||
|
|
||||
|
private final Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
@Override |
||||
|
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { |
||||
|
UUID uuid = UUID.randomUUID(); |
||||
|
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; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue