在 ClojureScript 中,如果抛出字符串并在“try”的封装“go”块中,则会忽略“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")))
;; 输出:无
(go (try (throw "THROWN") (finally (println "in a finally"))))