> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 09, 2004 10:16 AM
> To: Struts Users Mailing List
> Subject: RE: Best practices for localization of exception messages
> 
> 
> 
> 
> 
> 
> 
> 
> 
> "Jim Barrows" <[EMAIL PROTECTED]> wrote on 09/09/2004 01:00:11 PM:
> 
> >
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, September 09, 2004 9:52 AM
> > > To: Struts Users Mailing List
> > > Subject: RE: Best practices for localization of exception messages
> > >
> > >
> > >
> > >
> > >
> > >
> > > snip
> > >
> > >
> > > > 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.
> > > >
> > >
> > > So you don't include messages in the lower level exceptions?
> > > Do you base
> > > the message on the root exception?  How 'bout stacktraces?
> > > Do you log when
> > > the error occurs or in the Action when you finally catch the
> > > exception?
> >
> > I use the same pattern from SIA, so yes all that's included with the
> cause.
> >
> > So, from the dao:
> > catch( SQLException e){
> >    log.exception(e);
> >    throw new DaoFailureException( someVO.getPK(), e);
> > }
> >
> 
> I'm with you - mostly.  I'm trying to do the same thing - I think...
> 
> }catch( NamingException e ){
>       MessageUtility mu = 
> MessageUtility.getInstance(user.getLocale());
> 
>       throw new 
> LDAPException(mu.formatMessage(Constants.EXCEPTION_LDAP),
> e);
> }
> 
> If I follow you tho', where I'm forming a localized message, your
> someVO.getPK() is not a message but the value of whatever it was that
> caused the exception?  Then at a higher level you just form a 
> message based
> on the higher exception.

Yep, that's it.  I know what went wrong in general, and can drill down to the 
specifics if I need to for error reporting.
In general I always at least include the PK in a message, even for an exception that 
isn't related to the data (ie IOException from the jdbc layer etc).  Mostly for 
logging so I know what piece of data was being used.  I've also been known to 
.toString the value object for the message, again for tracking purposes when things go 
kablooooooey, especially on inserts.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to