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

[Question][ReScript] Possible to track promise rejections? #119

Open
sikanhe opened this issue Mar 5, 2021 · 1 comment
Open

[Question][ReScript] Possible to track promise rejections? #119

sikanhe opened this issue Mar 5, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@sikanhe
Copy link

sikanhe commented Mar 5, 2021

I wonder if it is possible to extend exception tracking to raise(Exception) and Js.Promise.reject called inside Js.Promise.make and Js.Promise.then and ensure they are caught with Js.Promise.catch.

If this works then it would be great for ReScript since that world doesn't use Result.t and converting between exception and Result can be painful.

Using Result type itself with promises can be painful when you often run into types like result<Promise.t<result<option<_>, _>>, _>. And for code paths that is most the green path, allocation Result types every time is less attractive than just raising exceptions, however we do lose type checking.

This would also be a huge sell when people compare ReScript to other languages like TypeScript since the latter has untyped errors and provide no help in tracking which errors can be caught.

@cristianoc
Copy link
Collaborator

That's a very good question.

A couple of aspects one would need to explore:

  • What it means to have "x called inside y". There are scoping rules for normal exceptions, but the mechanism used by promises is different.
  • What are sources of exceptions, in particular when binding to libraries.

@cristianoc cristianoc added the enhancement New feature or request label Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants