When using @ControllerAdvice
and @ExceptionHandler
annotations, along with some handler methods, I'm able to catch events from Exceptions thrown both by myself as by Spring Boot internally. For the handler to know which exception event to catch, I can use both the specific nested Exception class as a generic Exception class, as argument, at the handler... and it will catch the corresponding event.
I've not managed to catch one specific Exception event though, the one in which the user requests resources from a REST endpoint or path that doesn't exist at the @RestController... a "bad path". It just returns a 404 NOT FOUND response payload as a JSON, but I can't catch that at my @ControllerAdvice
@ExceptionHandler method in order to change the Response for that specific Exception event. Not even when using the top-level Exception.class can I catch this event... and I don't know the specific nested Exception class that Spring Boot uses when it throws this specific event, either.
Does anyone know what's the Exception class type whose instance Spring Boot throws when the user requests a "bad path" (inexistent endpoint) to the @RestController
of an application ?