directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: Exception Logging
Date Thu, 03 Jun 2010 21:41:39 GMT
On 6/3/10 11:15 PM, Felix Knecht wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> We have a lot of following constructs:
>
> log.error( I18n.err( I18n.ERR_04007 ) );
> throw new DecoderException( I18n.err( I18n.ERR_04007 ) );
>
> What about logging the exception within the exception itself like
>
> public DecoderException(String message)
> {
>      super( message );
>      log.error( message );
> }
>
>
> This will avoid having log.error all over the place and the translation
> must be done only once instead of twice like above.
>    

I would not favor such code pattern. The reason is that we may not want 
to log in all cases, but only from time to time. Also the log can 
contain a different message.

To avoid a double translation, I would rather suggest something like :
String message =

String message = I18n.err( I18n.ERR_04007 );
log.error( message );
throw new DecoderException( message );


-- 
Regards,
Cordialement,
Emmanuel L├ęcharny
www.nextury.com



Mime
View raw message