cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guido Casper <gcas...@s-und-n.de>
Subject Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Date Sat, 17 Apr 2004 09:00:34 GMT
Ugo Cei wrote:
> Guido Casper wrote:
> 
>> Ugo Cei wrote:
>>
>>> WebDAVRepository.java (swallowed):
>>>
>>>   } catch (ProcessingException pe) {
>>>     this.getLogger().error("Error saving dom to: " + this.repoBaseUrl 
>>> + uri, pe);
>>>   }
>>>
>>> WebDAVRepositoryPropertyHelper.java (swallowed):
>>>
>>>   } catch (ProcessingException pe) {
>>>     this.getLogger().error("Error serializing node " + value, pe);
>>>   }
>>
>>
>>
>> Ehm, I didn't follow all the discussions very closely, but if you want
>> to remove something please be aware that these Exceptions are not just
>> swallowed (don't know about the others) since after the catch clause
>> follows a "return false;"
> 
> 
> Indeed, we should carefully check every one of the samples I have 
> pasted, before changing them. Particularly those that don't rethrow an 
> exception.
> 
> At the very least, we can say that the usage of exceptions in this case 
> looks suspiciously like an instance of controlling the flow of the 
> application with exceptions.

Hmm, it seems to be conventional wisdom to use exceptions only for 
exceptional cases. But what is the definition of an exceptional case 
then (it's pretty clear what the "primary route" through this code is)? 
Exceptions are also a way to prevent my code from cluttering by 
constantly having to check return codes. And if you don't want every 
single exception being thrown to the user you have to consume it somewhere.

> 
> The problem is that the call that mandated the use of the "catch" might 
> fail and throw a runtime exception (say, a NPE) instead. If you want the 
> call to setProperty to always fail graciously, you'd better 
> catch(Exception) instead, don't you agree?

I'm still in my opinion finding phase on this :-) (wether to make 
ProcessingException a RuntimeException).

I think both "sides" have their points. In many cases it may be a matter 
of where and how you want to consume your exceptions.

Catching fine grained Exceptions doesn't buy me much in this case 
(except being able to put more meaningful messages into the logs).

Guido

-- 
Guido Casper
-------------------------------------------------
S&N AG, Competence Center Open Source
                     Tel.: +49-5251-1581-87
Klingenderstr. 5    mailto:gcasper@s-und-n.de
D-33100 Paderborn   http://www.s-und-n.de
-------------------------------------------------

Mime
View raw message