Closed
Description
Hi @fhammerschmidt,
https://rescript-lang.org/docs/manual/latest/promise is lacking a good sample on how to deal with Promise.catch
blocks.
It is still a bit unclear to me what exn
is. (Notice that I don't go to its definition in the IDE)
And how to unwrap exn
to something useful. This works, but I'm not sure if it is idiomatic or not.
let f = async () => {
Exn.raiseError("Hi!")
}
f()
->Promise.catch(async exn => {
switch exn {
| Exn.Error(exn) => exn->Exn.message->Option.getOr("yow")
| _ => "no error"
}
})
->Promise.done
Like, what else is there to catch if exn
is not Exn.Error
?
Would like to contribute a good example after receiving some guidance.
Metadata
Metadata
Assignees
Labels
No labels