geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Cabrera <>
Subject RE: Hardcoded message strings
Date Tue, 19 Aug 2003 12:17:19 GMT
I'm a big fan of formatting a message outside an exception class.  The
reason for this is that many times I want to log the error message before I
throw an exception.  Also, creating all these factory-like classes for every
exception seems daunting.  To be sure, we could create something even more
sophisticated but at the expense of obfuscating the code a bit.

With that said, this is something that must be resolved now because it is
very difficult to go back and properly i18n the code because everyone is
always on to the next big thing.  IMHO, this is much more important than the
package discussion that seems to be dragging on right now; not that the
package issue is not important too.


> -----Original Message-----
> From: Thomas Hawtin [] 
> Sent: Monday, August 18, 2003 7:09 PM
> To:
> Subject: Re: Hardcoded message strings
> Jason Dillon wrote:
> > Yes we should, please submit a patch (someone).
> It appears that very few programs put there exception messages in 
> resource bundles. I guess we expect anyone who reads them to be a 
> programmer and be able to read English even if not quite like 
> a native. 
> Also it's easier to edit the messages if they're inline. But 
> I won't let 
> that stop me.
> Attached is my stab at an answer. Some notes for discussion:
>   o If you tried replicating for a number of exceptions, the code 
> duplication would get horrific (and not even generics will save you). 
> I'm quite prepared to put together some XSLT, say, if necessary.
>   o Current version puts everything (ever) in one resource 
> file. However 
> from previous point, it may need replicating for each 
> project/subproject/package anyway.
>   o Might want to produce messages in a locale different from machine 
> set one (perhaps even do it a print time rather than throw time).
>   o Various points on generation of methods lazily and reuse of 
> MessageFormats can be criticised. Is there a better/more appropriate 
> formatter?
>   o I've put in an option not to fillInStackTrace (if using 
> lazy message 
> formatting), but that's probably asking for trouble. Of 
> course such code 
> can easily be chopped out.
> Tom Hawtin

View raw message