I have a spring-boot application. I have a class that is ControllerAdvice to handle the exceptions thrown by the app.
I created a filter that I want to use it to validate a header for all my requests. When I throw the custom exception from that filter, it does not go through my exception handler, it uses the default Spring error control.
Is there any way to handle the errors from filters in my own way?
You can write a controller that extends
BasicErrorControllerand write a method that has a@GetMappingannotation like this:There is my test filter:
This is result(but only get exception message not code): enter image description here