Can't we handle in this try { .... }catch (Exception e) { if( e instantceof JMSException || e instantceof RemoteException || e instance of SQLException){ ... } }
-----Original Message----- From: Brett Porter [mailto:[EMAIL PROTECTED] Sent: Sunday, November 21, 2004 4:26 AM To: Jakarta General List Subject: Re: Exception handling Was: Future JDK features 2 items I'm in favour of the multiple exception catch. I think the common use for this is to catch a series of checked exceptions in a certain way, while avoiding catching unchecked exceptions which you want to propogate. This is a good thing, because often I've seen code that catches Exception for brevity because it's considered to not be able to throw anything else, and later a NullPointer crops up and gets swallowed by the wrong handler, or a new checked exception gets introduced that is also caught where different handling may have been appropriate. As far as the common interface, I have no problem with the exception in this case being a Throwable. I think the JVM assigning the greatest common denominator base-class might be a little too much magic. And "as" syntax is pretty crowded when you can do that in a cast in the handler. But a lot of handlers are logging or wrapping in a new exception so the type is irrelevant. Cheers, Brett On Sat, 20 Nov 2004 14:45:37 -0500, Noel J. Bergman <[EMAIL PROTECTED]> wrote: > > > > try { > > > > .... > > > > } catch( (JMSException | RemoteException | SQLException) e) { > > > > } > > > > try { > > > ... > > > } catch (Exception e) { > > > ... > > > } > > > Usually you don't want to just catch all exceptions in a single block. > > Instead you want to have clusters of exceptions > > And what is the common interface for those exceptions? Exception? ;-) Are > you looking for catch (<TypeList> As <ParentType>), and just want the JVM to > exclude out other types derived from ParentType? > > --- Noel > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]