You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Schumeyer <rs...@ieee.org> on 2006/10/31 14:31:52 UTC

Exception handling best practices: ModuleException

I would appreciate any insights people have on the best way to handle 
exceptions.  I would really like to keep it simple, and not create a 
custom exception handler or whatever if I don't need to.

I ran across ModuleException, mentioned in the Jakarta Struts book by 
Cavaness (2nd ed for struts 1.1).  This seems like a fairly pain-free 
way to throw an exception that is wrapped around an ActionError, 
providing for localized error messages. 

However, the author warns that using this ties your application to 
struts.  Is this really a big problem?  I don't think I'm going to be 
handling exceptions in my business code, only in the controller code.  
(The business code may throw them; I don't plan to handle them until 
they bubble up to the controller.) (Of course, please let me know if 
this is a bad idea.)  The controller code is, obviously, already tied to 
struts!  So I see this warning as a non-problem.  Am I missing something?

I plan to use declarative exception handling, hopefully in combination 
with ModuleException.  At some point, I will end up in a jsp page and 
need to print out the contents of the ActionError within the 
ModuleException.  Does anyone have an example of how to do this?

Thanks again for the list's help!







---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org