I want to use generic way to manage 5xx error codes, let's say specifically the case when the db is down across my whole spring application. I want a pretty error json instead of a stack trace.
For the controllers I have a @ControllerAdvice class for the different exceptions and this is also catching the case that the db is stopping in the middle of the request. But this is not all. I also happen to have a custom CorsFilter extending OncePerRequestFilter and there when i call doFilter i get the CannotGetJdbcConnectionException and it will not be managed by the @ControllerAdvice. I read several things online that only made me more confused. 
So I have a lot of questions:
- Do i need to implement a custom filter? I found the ExceptionTranslationFilterbut this only handlesAuthenticationExceptionorAccessDeniedException.
- I thought of implementing my own HandlerExceptionResolver, but this made me doubt, I don't have any custom exception to manage, there must be a more obvious way than this. I also tried to add a try/catch and call an implementation of theHandlerExceptionResolver(should be good enough, my exception is nothing special) but this is not returning anything in the response, i get a status 200 and an empty body.
Is there any good way to deal with this? Thanks
 
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    