From the course: Spring: Spring MVC

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Global exception handler for application

Global exception handler for application

From the course: Spring: Spring MVC

Start my 1-month free trial

Global exception handler for application

- In the previous video, we established the entire login flow and we also did an exception handling for that login flow. Now, when we did the exception handling, if you remember, we were in the LoginController, we tried to throw something from there and the exception handler was written in the LoginController itself. However, sometimes you may have a requirement to apply this exception handler to all exceptions that occur in any of your controllers. So what I'm trying to tell you here is that we may need to set up a global exception handler for the entire application. So no matter which controller throws exceptions, you need to make sure that the same kind of exception handling mechanism applies. So that's the demo that we're now going to do. Let's see the slide for the steps. You first add a class for the exception handler. So this is the global exception handler that we are adding now. So let's go back to the IDE…

Contents