Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 16439 invoked from network); 14 Apr 2004 14:24:31 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 14 Apr 2004 14:24:31 -0000 Received: (qmail 43305 invoked by uid 500); 14 Apr 2004 14:24:23 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 43076 invoked by uid 500); 14 Apr 2004 14:24:22 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 43057 invoked from network); 14 Apr 2004 14:24:21 -0000 Received: from unknown (HELO mail.s-und-n.de) (212.8.217.2) by daedalus.apache.org with SMTP; 14 Apr 2004 14:24:21 -0000 Received: from notes.sundn.de (ntsrv5.sundn.de [10.10.2.10]) by mail.s-und-n.de (postfix) with ESMTP id 3928819F5D3 for ; Wed, 14 Apr 2004 16:24:23 +0200 (CEST) Received: from hw0386 ([10.10.2.54]) by notes.sundn.de (Lotus Domino Release 6.5) with ESMTP id 2004041416173174-54799 ; Wed, 14 Apr 2004 16:17:31 +0200 From: "Carsten Ziegeler" To: Subject: RE: [RT] Checked exceptions considered harmful Date: Wed, 14 Apr 2004 16:26:48 +0200 Organization: S&N AG MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Thread-Index: AcQiKWvAUqj21KxeTUOrV65W9s6EEQAAl27Q In-Reply-To: <407D4512.70700@cbim.it> X-MIMETrack: Itemize by SMTP Server on PBSN1/Systeme und Netzwerke(Release 6.5|September 26, 2003) at 14.04.2004 16:17:31, Serialize by Router on PBSN1/Systeme und Netzwerke(Release 6.5|September 26, 2003) at 14.04.2004 16:17:32, Serialize complete at 14.04.2004 16:17:32 Message-ID: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Ugo Cei wrote: > > Carsten Ziegeler wrote: > > In general I agree with Bertrand that it's nicer to add a "throws > > Exception" to an Interface to tell the user that something can go > > wrong. > > You will get to add a "throws Exception" to any method only > over my dead body ;-). > Be carefull with what you wish... :) Seriously, I don't want to change any interface, but I think if an exception can occur it's easier to say "throws Exception" than to say "throws MySpecialException1, MySpecialException2" etc. But at the same time, special exceptions like the ResourceNotFoundException should be declared in the throws clause, as you might recover from them. So perhaps it's better to distinguish between Exceptions (that you might recover from) and Errors. But unfortunately, the client should be the one deciding that the exception is recoverable and not the called component. > > And we shouldn't forget that some exceptions are treated > differently, > > for example the ResourceNotFound exception (that's the > reason for the > > ugly exception handling code in SourceUtil). This exception > is treated > > by the sitemap engine differently from other exceptions and we > > shouldn't loose this feature. > > Indeed. That's why I propose that ProcessingException extends > CascadingRuntimeException, instead of CascadingException. > This way, you won't be forced to catch it (and catch > ResourceNotFoundException) if you don't need to and be > tempted to wrap it or swallow it. > > The sitemap engine can continue catching it as it does now. > > The litmus test should be the following: can you recover from > a ResourceNotFoundException, in the general case? IMHO, no. > Your best course of action is to tell the user. > > If I'm not mistaken, reparenting ProcessingException would > require zero changes in other components, it would be a > totally backward-compatible change, but could allow us to > remove lots of useless code. So I'm proposing to do this for 2.1.5. > Hmm, yes this change is backward-compatible but has the danger that you simply forget to check for a recoverable exception as you don't notice that it's thrown. Difficult. Carsten