Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When non-Error values are thrown they aren't be caught by :default #114

Closed
kanaka opened this issue Jan 13, 2022 · 4 comments
Closed

When non-Error values are thrown they aren't be caught by :default #114

kanaka opened this issue Jan 13, 2022 · 4 comments

Comments

@kanaka
Copy link

kanaka commented Jan 13, 2022

version

0.1.0

platform

Ubuntu 20.04.3 with 16.10.0

problem

Normal ClojureScript (and JavaScript) can catch normal (non-Error) values when they are thrown, but nbb is not catching them.

repro

user=> (try (throw (js/Error. "blah")) (catch :default e (prn :e e)))
:e #object[Error Error: blah]
user=> (try (throw "blah") (catch :default e (prn :e e)))
"blah"

expected behavior

Same as ClojureScript:

cljs.user=> (try (throw (js/Error. "blah")) (catch :default e (prn :e e)))
:e #object[Error Error: blah]
cljs.user=> (try (throw "blah") (catch :default e (prn :e e)))
:e "blah"

Note that this is functionality supported natively by JavaScript itself:

> try { throw("blah") } catch (e) { console.log("e:", e) }
e: blah
> try { throw([1,2,3]) } catch (e) { console.log("e:", e) }
e: [ 1, 2, 3 ]
@borkdude
Copy link
Collaborator

wat? I didn't know this was possible!

@borkdude
Copy link
Collaborator

Fixed in SCI. Will bump after I fix #115

@kanaka
Copy link
Author

kanaka commented Jan 13, 2022

Verified both this and #115. Thanks!

@borkdude
Copy link
Collaborator

@kanaka You're welcome. If you are using nbb at work or in an OSS project, it'd be great if you shared something about it here:

#91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants