在Clojure中捕获多个异常并处理它们

iGE*_*GEL 2 exception-handling exception clojure

这有点类似于这个问题,但我希望捕获多个异常并处理它们.在Ruby中,我可以写

begin
  rand(2) == 0 ? ([] + '') : (foo)
rescue TypeError, NameError => e
  puts "oops: #{e.message}"
end
Run Code Online (Sandbox Code Playgroud)

我可以在Clojure中做同样的事吗?现在我let是一个功能,只需在每个catch身体中调用它.

ako*_*ond 7

(ns mastering.stackoverflow
    (:use
        [slingshot.slingshot :only [try+]]))


(try+
    ; ...
    (catch (comp #{TypeError NameError} class) _ "caught"))
Run Code Online (Sandbox Code Playgroud)

弹弓库可在github上找到.