tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Drye" <sd...@atg.com>
Subject Re: <exception> tag (was: Re: I18N: <bundle> Bug?)
Date Thu, 20 Dec 2001 15:39:57 GMT
> > The usual thing to do with exceptions in a i18n environment is to throw
a
> > code for the message, not the actual message.  Then you just use the
code as
> > a key to look up the localized message in a properties file.  This way
> > there's no need to use any custom exceptions.
>
> In the approach you are describing, the code (or key) of the exception
message
> is looked up in the application's configured resource bundle, and the
> message it maps to is passed into the exception's constructor before the
> exception is thrown, like this:
>
>   throw new XXXException(Resources.getMessage("SOME_ERROR_CODE"));

Forgot to mention that the libraries I write that use this technique have a
getExceptionText(key, locale) static method.  So, the client code just calls
back into the library to get the text of the message after the exception is
caught.

So, the lookup is TheLibrary.getException(except.getMessage(),
response.getLocale()) in a JSP environment.

Stephen Drye
Art Technology Group


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message