I have wrote following controller to handle all exception in my code:
@Controller
public class ErrorHandlerController {
@ExceptionHandler(value = Exception.class)
public String redirectToErrorPage(Model model){
model.addAttribute("message", "error on server");
return "errorPage";
}
}
But looks like following exception handler will work only if exception throws inside ErrorHandlerController
I have a huge count of controllers. Please advice me how to write one ExceptionHandler for all controllers ?
P.S.
I understand that I can use inheritance but I don't sure that it is the best decision.