CocoaScript icon indicating copy to clipboard operation
CocoaScript copied to clipboard

Catch global errors from JS

Open appsforartists opened this issue 7 years ago • 1 comments

Is it possible to register a global exception handler from within JS executed by CocoaScript?

In a typical environment, this can be done with addEventListener('error', …), but of course the global object doesn't have an addEventListener in a JSContext.

Peeking through the Mocha codebase, I didn't see an obvious place to do this. I see a setErrorController in your codebase, but it looks like that's being used in a REPL, not in the runtime itself.

appsforartists avatar Mar 29 '18 04:03 appsforartists

Maybe the fiber API could have a way to trigger a callback when an error occurs while that fiber is active.

appsforartists avatar Mar 29 '18 04:03 appsforartists