Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Errors by

Java 7 and up support multi-catch exceptions (http://www.oracle.com/technetwork/articles/java/java7exceptions-486908.html). It would be handy if Clojure also supported them to prevent catching something like Exception and then writing manual logic to check the Exception type, or duplicating the logic over multiple catch blocks.

A possible syntax for this could be:

`
(try (fn-that-throws)

 (catch (UnknownHostException NoRouteToHostException) e
   (go-offline)))

`

Prior art for this is a * } macro: https://gist.github.com/Gonzih/5814945.

One nuance to handle is

{quote}
Edit: Note that in Java 7, you cannot both catch ExceptionA& ExceptionB in the same time, if ExceptionB is inherited(directly or indirectly) from ExceptionA. Compiler will complain: The exception ExceptionB is already caught by the alternative ExceptionA. - http://stackoverflow.com/a/3495968/826486
{quote}

I tried searching to see if this had been asked already, but got mountains of results. I didn't see anything in the first few pages though.

by
I ran into a use-case for this. It would be a welcome change without relying on libraries or macros such as slingshot's `try+`.

1 Answer

+1 vote
by
Reference: https://clojure.atlassian.net/browse/CLJ-2124 (reported by desk@danielcompton.net)
...