directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <akaras...@apache.org>
Subject Re: Exception Logging
Date Sat, 05 Jun 2010 08:37:26 GMT
On Sat, Jun 5, 2010 at 11:35 AM, Alex Karasulu <akarasulu@apache.org> wrote:

> On Fri, Jun 4, 2010 at 3:55 PM, Alan D. Cabrera <list@toolazydogs.com> wro
>
>>
>> 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.
>>
>> This is not a very good pattern for a number of reasons.
>>
>> 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.
>>
>>
> +1
>
>
>> 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.

-- 
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

Mime
View raw message