<confused-look-on-face> Erik -
How then do you return a simple status from your business model to your action? There is not an 'exceptional condition' - simply a return value that the action can use to select the appropriate forward (for instance). As I've been looking into using exceptions to handle this, it appears that I've swapped a series of if-then-else constructs for a series of try-catch-catch blocks. So let me re-phrase my question - when a business model needs to return a status (not an exceptional condition (i.e. SQLException)), what is the 'best practice' for doing this? </confused-look-on-face> Jerry Jalenak Team Lead, Web Publishing LabOne, Inc. 10101 Renner Blvd. Lenexa, KS 66219 (913) 577-1496 [EMAIL PROTECTED] -----Original Message----- From: Erik Price [mailto:[EMAIL PROTECTED] Sent: Monday, August 11, 2003 11:05 AM To: Struts Users Mailing List Subject: Re: [OT - Slightly] Returning Error Status from Business Layer Jerry Jalenak wrote: > Erik - > > Thanks. I'm beginning to look at ways to handle returning status using > exceptions. The idea of 'wrapping' each exception by layer is very > appealing.... No problem. While exceptions are awesome, I don't want to give the impression that they should be used for everything -- while in other languages such as Python, it is traditional to use exceptions for basic execution control flow (i.e., an infinite loop that is only broken by a thrown exception), in Java the idiomatic use of exceptions is that they are only used in "exceptional circumstances", generally when there is a problem of some sort. Also, AFAIK throwing an exception uses more resources than simply making a conditional decision. There is a great chapter in Joshua Bloch's book "Effective Java" on best-practices for using exceptions. If you find that a lot of your code looks like a long string of "if... else" statements or switch statements then you may wish to research Martin Fowler's "Replace Conditional with Polymorphism" refactoring. Regards, Erik --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This transmission (and any information attached to it) may be confidential and is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient or the person responsible for delivering the transmission to the intended recipient, be advised that you have received this transmission in error and that any use, dissemination, forwarding, printing, or copying of this information is strictly prohibited. If you have received this transmission in error, please immediately notify LabOne at the following email address: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]