On Jan 25, 4:22 pm, David Powell <djpow...@djpowell.net> wrote: > On 25 Jan 2011 06:04, "Shantanu Kumar" <kumar.shant...@gmail.com> wrote: > > > > > The changed code should catch 'Exception', not 'Throwable' because the > > latter is a common ancestor of both 'Exception' and 'Error'. An > > 'Error' must not be swallowed at any point in the system, unless you > > are writing an app server or a JVM implementation. ;-) > > Throwable is better I think. The idea is to be a more robust try/finally > construct, and finally still runs if an Error is thrown. There is no > problem temporarily catching Throwable as long as you don't swallow it.
I can't see the value in catching Throwable and then re-throwing it; idiomatically Throwable is rarely caught. Looking at code example, the following two snippets below are just the same: (try (.close resource) (catch Throwable t (when (instance? Error t) (throw t)))) (try (.close resource) (catch Exception e)) Besides, looking at the Java spec http://download.oracle.com/javase/6/docs/api/java/lang/Error.html ------ An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it. A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur. ------ Regards, Shantanu -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en