You can still do that, but wrapping specific exceptions you expect. If
you answer to that "but I don't know all the exceptions I can expect", I
would reply "that is reasonable, but then any non-expected exception
should not be wrapped, otherwise you add noise and make the problem more
difficult to fix".
On 02/07/12 14:57, Luping wrote:
> Basically I agree with you.
> But, I want to handle all exceptions in the top tier, that's why in the
> others tiers, I have created a series of personals exceptions like
> DALException, ServiceException ...... to wrap and rethrow those
> originals exceptions.
>
>
> Le samedi 30 juin 2012 05:28:37 UTC+2, Bevan a �crit :
>
> On 29/06/2012 11:56 p.m., Andres G. Aragoneses wrote:
>> It *is* a real violation because you're catching Exception instead
>> of a derived class of Exception.
>>
>> Normally apps have an isolated place with a catch-all though, but
>> just one. And this is the only one which you should add to your
>> Gendarme ignore-list.
>
> Catching Exception (and not a derived class) in order to wrap the
> original exception with additional information to give context for
> the original error is a pretty common pattern, at least in the code
> I've encountered.
>
> The key is that you're not catching the exception with an intent to
> *handle* it, but simply to provide additional context by wrapping it
> with addition information.
>
> Sometimes the only diagnostic you get is the exception message
> heirarchy and the extra context is invaluable.
>
> My 2c,
> Bevan.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Gendarme" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/gendarme/-/DFPiEf4WC_wJ.
> To post to this group, send email to
>
gend...@googlegroups.com.
> To unsubscribe from this group, send email to
>
gendarme+u...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/gendarme?hl=en.