要在Clojurescript中捕获JavaScript异常,请尝试以下代码片段-
(js/Error. "Oops") ;; throw error (throw (js/Error. "发生了错误!")) ;; catch error (try (throw (js/Error. "Erro occurred")) (catch js/Error e e)) ;; JavaScript allows to throw anything, but handle it with ClojureScript (try (throw (js/Error. "发生了错误! ")) (catch :default e e))