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

Exception catching mode. #165

Open
back2dos opened this issue Oct 20, 2021 · 2 comments
Open

Exception catching mode. #165

back2dos opened this issue Oct 20, 2021 · 2 comments

Comments

@back2dos
Copy link
Member

back2dos commented Oct 20, 2021

Via e.g. -D tink_core.catch_exceptions a few try/catch barriers would be added:

  1. in Promise.next/new/irreversible exceptions would be propagated as errors.
  2. In Callback.guardStackoverflow (which is where almost all dispatching goes through) any exceptions would be caught and reported, as well as all other places that call user code (e.g. CallbackLink.cancel).
  3. Add some Error.oncaught((e.Exception)->Void) where user can add errors reporters (if none are added, use console.error on JS and the closest possible thing on other platforms).
@gene-pavlovsky
Copy link
Member

How is it going with this?

Meanwhile I made a small test program which checks how it works with both signals and observables. The results are more scary than I thought. If any signal handler / observable binding throws an exception, not only this prevents other handlers / bindings from being called with the current signal / state change, but none of the handlers/bindings ever run again on further signals / state changes.

exception-test.tar.gz

@gene-pavlovsky
Copy link
Member

gene-pavlovsky commented Feb 2, 2024

P.S. Adding exception handling to guardStackoverflow only makes sense if the code wrapped by it can survive an exception being thrown. E.g. if one of the cells in CallbackList.invoke throws, the object will be left in a bad state (with busy: true), regardless of any exception handling done by guardStackoverflow.

Otherwise I think the changes proposed in the issue description would be good to have ASAP :)

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