The DataAccessException error is ignored after exiting the dao scope.
And this is good! Let it fly through the whole stack. Probably you have transactions at the service level - an exception will transparently lead to the rollback of an external transaction. Fine!
Now he will find his way to the controller. If you catch it in the Struts controller, you can, for example, return a different view. But most likely you do not want to handle the exception in every Struts action. Therefore, let the exception fly even further. At some point, Struts will catch this exception and try to handle it. Struts has several complex error handling mechanisms, you will find a lot of information about them. Typically, it will trigger some custom actions or error screen depending on the type of exception.
Finally, even if Struts cannot handle the exception, it will be returned to the container, with the result that HTTP 503 with the exception data will be returned.
As you can see, you can control exceptions at many levels, usually better.
Tomasz Nurkiewicz
source share