On Sat, Jun 5, 2010 at 11:35 AM, Alex Karasulu <email@example.com>
On Fri, Jun 4, 2010 at 3:55 PM, Alan D. Cabrera <firstname.lastname@example.org> wro
This is not a very good pattern for a number of reasons.
On Jun 3, 2010, at 2: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.
First, you cannot control logging at the source of the error. Admittedly this is an error message but I have run into times where I want to turn off the klaxon to see what the real problem is.
Second, constructors should not have side effects. It's never a good idea.
Third, I never log an error if I am throwing an exception. It just adds noise. I will, however, log additional useful information that is not in the exception message. Just parroting what's in the exception is of little value.
Finally, what the heck is ERR_04007? :) I thought there already was a discussion and community consensus about how there is little to negative value in using numbers as error messages. Maybe I missed the conversation where this opinion was reversed. If so, ignore this bit. :)
+1 - we need to find a way to make this easier to read either with the IDE's help or other.
Pardon I realized this was discussed further and that I had not read this completely. Retracting the +1. Too much mail.