0

I need to create a global exception handler just to log what data sent caused the exception with some other little things and, after this, go on with the normal exception handling on my application.

I tried a lot of things, but im putting the last one down here.

@Order(Ordered.HIGHEST_PRECEDENCE)
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public void handleException(HttpServletRequest request, Exception ex) throws Exception {
        log.error("[ERROR]: {}, Route: {}, Method: {}, Data sent: {}", ex.getMessage(), request.getRequestURL().toString(), request.getMethod(), request.getParameterMap().toString());

        throw ex;
    }
}

The truly problem is that nothing happens. I already put a sysout here and it does not enter in the handler with any exception

0 Answers0