On Fri, Jun 4, 2010 at 12:41 AM, Emmanuel Lecharny <elecharny@gmail.com> wrote:
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 );


+1

Also although perhaps unrelated ... can't we get eclipse to show the error message when doing a mouse over or something on the I18n error code? 

--
Alex Karasulu
My Blog :: http://www.jroller.com/akarasulu/
Apache Directory Server :: http://directory.apache.org
Apache MINA :: http://mina.apache.org
To set up a meeting with me: http://tungle.me/AlexKarasulu