Welcome to Simple Programming
@Exceptionhandler used to catch any exception in a controller
You can have multiple methods annotated with exception handler inside this controller with valid exceptions.
Drawback:
these exception handlers are active only inside that controller. we don’t want that, and that is not a good coding strategy.
If there are multiple controllers, we need to segregate the exceptions handlers into a common class so that it looks elegant and easy to maintain in future
There is an annotation available that makes it happen, it is called @ControllerAdvice
let us see how it works in our next video
Thanks for watching and please subscribe for more such videos