This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi all I have my application working pretty well - in a good portion thanks to help from all of you. I am now getting database connections in place and pulling data from the db instead of using test data. My question is what is the best practice for error handling for any of the errors that can come from the db such as the sqlException or Exception. What would make sense - throwing the error, and if the caller receives an error to call an error page ?
The best practice would be to use a mix of declarative exception handling and non-declarative exception handling.
For example, you may want to use declarative exception handling to handle exeptions if the database cannot be connected. You would not want to use declarative exception handling when validating user entered values (i.e. an entered value must be a number).
Another option (but probably not the best practice for struts) is to have all of your classes extend the org.apache.struts.action.Action class (which they should do already) and override the execute method and handle all of you exceptions in there.