• 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

Any recipes for Exception handling

 
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Authors,

Does your book have any recipes for exception handling, especially on how to use declarative exception handling, best pracices for exceptions, tips, traps etc..
Also, which one is better, programatic handling or declarative handling??

thanks
 
author
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, we do. We have two.

Recipe 5.4 Use declarative exception handling uses a use case to illustrate how to implement declarative exception handling. The key to implementing it well is to make sure you have a well thought out exception strategy. Its important to spend a little time to come up with an inheritance hierarchy that suits your architecture. In this recipe we illustrate a sample strategy and show how it dove tails into declarative exception handling.

It is a best practice to always create a global exception tag to catch anything that might slip through. Its a graceful way to handle the unexpected. The best practice reads as follows ...


Best Practice: Always create a global exception tag to catch java.lang.Exception

Under Struts 1.1, an Action's execute method allows an unintentional return of an exception descending from java.lang.Exception. Unless these exceptions are caught by the ExceptionHandler, the user will receive a "Server Error 500". A graceful way to handle this unexpected condition is to create a global exception tag to handle java.lang.Exception.



We also have another recipe that shows you how to deal with an aggregation of exceptions (5.5 Aggregate exceptions). Often you will want to discover as many issues up front and aggregate then into a single exception. In this recipe we show you how to roll your own ExceptionHandler to deal with an aggregation of exceptions.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic