Skip to content

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

Open
@sikanhe

Description

@sikanhe

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions