I am working on JSF, Spring, IBatis based application.
I am looking for better of doing exception handling.
I have 2 approaches to do exception handling
1) First approach =================== All DAO methods are throwing SqlException. All business logic methods, are catching these SqlException and converting them to Application exception. All beans are catching these Application Exception and adding one message in a global ArrayList. JSF page, will show all value from ArrayList.
2) Second Appproach ==================== All DAO methods are throwing SqlException. All business logic methods, are catching these SqlException and converting them to Application exception. All beans are catching these Application Exception and adding meesage in FacesContext and returning FAILURE as a return value. NavigationHandler gets this FAILURE value and redirects to the error page, which will display all messages from FacesContext
First do you see any problem in any of the approach mentioned above? If yes then please let me know the problem and solution.
If not then please do let me know is there any other approach possible to do exception handling in more better way.
In the second approach do we have to use "action" attribute?
Dhananjay Inamdar
Ranch Hand
Joined: Jan 27, 2003
Posts: 130
posted
0
Hi Sateesh,
Finally we used one another approach for exception handling in our application.
But to answer your question, I don't see the necessicity for using 'action' in second approach.
Our final approach is:
1) We are using ORM layer integrated with Spring. 2) Spring is throwing DataAccessException, which is inherited from RunTimeException 3) So now our ORM methods no need to add any exception in throws clause 4) In Service/ business layer methods, who are intereacting with ORM layer, they depends on the scenario catching the exception either they are also not doing anything on exception 5) We have configured RunTimeError in WEB.XML and soowing one error page, with all infomration about the error.
Please let me know if you want clarification on this new approach.