Closed scull7 closed 6 years ago
Yes, this is a great reference, thank you.
Do you have any ideas on how to differentiate between different errors? For example, imagine a postgres query potentially throwing a NoSuchColumn
error or a NotUnique
error. In normal JS one could write if err instanceof NotUnique)
. I'm wondering if that's possible to translate to reason (I haven't given much thought to it yet).
The exn
function parameter pushes this responsibility to the caller. They are free to implement whatever scheme they like
That's true, and is probably the best way to do it 👍
Shall I make a PR?
Yes please :) Put it in a new file FutureJs.re
and name it fromPromise
. I'd like to keep JS-specific code in its own module, if that makes sense.
I've added the FutureJs.fromPromise
method and associated tests.
Here is the function that I'm using for Js.Promise conversion:
Perhaps this may be useful?