james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefano Bagnara <apa...@bago.org>
Subject Re: Error Handling In JDBCMailRepository
Date Wed, 01 Aug 2007 22:27:34 GMT
Robert Burrell Donkin ha scritto:
> JDBCMailRepository contains several examples of exception handing similar to:
> 
>         } catch (Exception me) {
>             throw new MessagingException("Exception while retrieving
> mail: " + me.getMessage());
>        }
> 
> the downside with this approach is that information about the original
> exception (including the stack trace) are lost. (i'm getting a null
> pointer thrown but without a stack trace it's hard to know where the
> problem lies.)
> 
> any reason why changing these to:
> 
> } catch (Exception me) {
>    getLogger().debug("XXX", me);
>    throw new MessagingException("Exception while retrieving mail: " +
> me.getMessage(), me);
> }
> 
> would be a bad idea?
> 
> - robert

+1

I think it is simply old code that has never been refactored.
About the getLogger().debug() I would probably avoid it as it can be
done by the caller when he intercept the new MessagingException.

I usually prefer to log only when I catch and not rethrow (or loose
informations rethrowing) otherwise I leave logging to the caller.

Having the same problem logged multiple times is sometimes misleading.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message