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?)