> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 09, 2004 9:01 AM > To: [EMAIL PROTECTED] > Subject: Best practices for localization of exception messages > > > > > > > > I'm learning and building as I go and have run into a > situation that I'm > not sure if I'm handling right. > > I've started using chained exceptions per the suggestion in Struts in > Action. I'm also trying to localize the messages. What I'm > not sure of is > the best way to get the locale down to the lower layers where > the chained > exception originates.
You don't. It doesn't belong down there. Throw an exception, and use the exception to tell your UI what message to display. > > I haven't passed the session or request objects down in order > to keep the > business layer from knowing what's going on in the V & C > layers. Instead, > I've passed a User object down that has the locale. What I > don't like tho' > is that I've got all these method calls with the User being > passed in. Is > there a better way? Is it overkill to keep the session > object out of the > business layer when I know this will only be a web app? You don't know this is only a web app. It could be turned into a web service tomorrow. :) You're right to not like that. Error message display is a UI thing. I'll catch an SQLException, put it in a DAOFailureException ( which inherits from DaoException typically), throw it. BO catches, rolls it into an DataStoreFatalApplicationException (which inherits from FatalApplicationExcpetion, which inherits from BOException), and throws it up to the UI, which handles figuring what to display to the user. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]