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

0 votes
in core.async by

In ClojureScript, (catch :default e ...) in a go block fails with non-js/Error` classes. That is, throwing e.g. a number, a String, etc. fails (not that this is good practice anyway, but still). I came upon this while porting Slingshot (scgilardi/slingshot) to CLJS.

Given the following tests:

`
(defn test0
"Prints 'Error: nil'."
(link: )
(go (println "Error:"

    (<! (go (throw (js/Error.)))))))

(defn test1
"Prints 'Error: #object(link: Error Error)'."
(link: )
(go (println "Error:"

    (<! (go (try (throw (js/Error.))
                 (catch :default e e)))))))

(defn test2
"Doesn't print anything in addition to the console error
msg. Chrome says 'Uncaught 123'."
(link: )
(go (println "Error:"

    (<! (go (try (throw 123)
                 (catch :default e e)))))))

`

test2 should print 'Error: 123', but doesn't.

(As a sidenote, shouldn't test0 return the thrown js/Error instead of printing to the console that there was an uncaught error and returning nil?)

2 Answers

0 votes
by

Comment made by: alexandergunnarson

Sorry, I should have specified that this is for ClojureScript version 1.9.93 and core.async version 0.2.385. Also forgive the lack of markup.

0 votes
by
Reference: https://clojure.atlassian.net/browse/ASYNC-172 (reported by alex+import)
...