Would a good solution to this be for try/catch to _automatically_ unroll RTE if there's no matching Exception class specified?
I understand _why_ the change to wrap exceptions was made but without the equivalent unwrapping in try/catch this just moves the pain from the library/language out to the users, yes? Sean On Sat, Oct 8, 2011 at 11:10 PM, Constantine Vetoshev <gepar...@gmail.com> wrote: > I finally came up with a simple example which shows the broken > exception handling behavior I described in my earlier post on this > thread. > > (defn broken-catch [filename] > (try (java.io.FileReader. filename) > (catch java.io.FileNotFoundException fnfe > "FileNotFoundException caught") > (catch RuntimeException ioe > (str "RuntimeException caught; cause: " > (.getCause ioe))))) > > user=> (broken-catch "/etc/passwdXYZ") > "RuntimeException caught; cause: java.io.FileNotFoundException: /etc/ > passwdXYZ (No such file or directory)" > > The FileReader constructor throws a FileNotFoundException when the > file specified by the argument does not exist: > http://download.oracle.com/javase/6/docs/api/java/io/FileReader.html#FileReader(java.lang.String) > — and as you can see here, Clojure 1.3.0 wrapped it in a > RuntimeException, so the expected typed catch does not work. > > However, if invoked in a way which bypasses reflection, the exception > is properly typed: > > user=> (try (java.io.FileReader. "/etc/passwdXYZ") > (catch java.io.FileNotFoundException fnfe > "FileNotFoundException caught") > (catch RuntimeException ioe > (str "RuntimeException caught; cause: " > (.getCause ioe)))) > "FileNotFoundException caught" -- 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