• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error handling

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic