[Question][ReScript] Possible to track promise rejections?
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.
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.