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


Reply via email to