ClojureScript中,如果在一个“go”块的“try”包围中抛出一个字符串,则“finally”将被忽略。
示例代码
(ns demo
(:require-macros
(link: cljs.core.async.macros :refer [go]))
;; 输出: "in a finally"
(go (try (throw (ex-info "THROWN" nil)) (finally (println "in a finally"))))
;; 输出: "in a finally"
(go (try (throw (js/Exception. "THROWN")) (finally (println "in a finally"))))
;; 输出: "in a finally"
(go (try (throw (#js {})) (finally (println "in a finally"))))
;; 输出: "in a finally"
(try (throw "THROWN") (finally (println "in a finally")))
;; 输出: nothing
(go (try (throw "THROWN") (finally (println "in a finally"))))