planck-repl / planck

Stand-alone ClojureScript REPL
https://planck-repl.org
Eclipse Public License 1.0
1.03k stars 68 forks source link

Support for global uncaught exception handler? #625

Open daemianmack opened 6 years ago

daemianmack commented 6 years ago

Hey, I'm curious if Planck allows defining a global uncaught exception handler?

e.g. in Lumo I would do something like this...

(.on js/process "uncaughtException" #(js/console.error (js/Date.) "uncaughtException" %))
mfikes commented 6 years ago

@daemianmack There is no facility in Planck itself. I wonder if there is a JavaScriptCore equivalent to your example above. Failing that, I suspect we could add something somewhere to catch things. Does this tend to occur with callbacks or core.async?

daemianmack commented 6 years ago

Not currently in pursuit of any particular use-case; at the moment I'm making do with a top-level try/catch but was curious if there was another option.

mfikes commented 6 years ago

@daemianmack Cool. A while back, I made some improvements to ensure that if you run a script, and it fails by throwing, then Planck will itself report the exception. Perhaps this covers the main concern. I'd be curious to know if you actually need your top-level try / catch and if Planck's inherent reporting works in your case.

daemianmack commented 6 years ago

In this case we want to do some cleanup as part of the catch, so it needs to be custom. Definitely appreciate the auto-throw though. :)