This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error handling

 
A knibbs
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

thanks in advance.
 
Dom Lassy
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.objectsource.com/j2eechapters/Ch18-Exception_Handling.htm

Start at 18.7 Exception handling - Struts way.

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic