Exception handling in web involves Spring Hibernate and Struts
posted 8 years ago
I need to know what is the better approach for handling exception.
My web project is having Struts-Spring and Hibernate.
I am following the below coding style.
An exception can occur eitehr at Struts Action or Biz Layer or at Data Layer.
For suppose in Data Layer, I am getting the duplicate excepion from DB what will be better approach to handle it. Whether I need to send it back the same exception to Biz layer and then to Action and display it to the user.
Also, how can I handle different exceptions to the user. For example while the user trying to add a new employee details, duplicate error might come and on what basis I can get the error and display it the user appropriately .
Since I will be configuring exception in applicationContext.xml in transaction for rollback/commit, i want to handle it correctly.
Please advice on the better approach in handling the exception for the above model. thanks.