Hej, I have this piece of code
BsFirebase.Auth.signInWithEmailAndPassword(
Firebase.auth,
~email=self.state.email,
~password=self.state.password,
)
|> Js.Promise.then_(_user => {
// ...
})
|> Js.Promise.catch((error) => {
// ...
})
|> ignore;
In the catch, the error field includes a field code
that I can use to have more details about the error.
I'm trying to write a wrapper function to cast the error
to a "custom" type but I have no idea how to do it.
So far I have (thanks Jared)
type firebaseError = {"code": int, "message": string}; /* etc. */
external unsafeCeorceToFirebaseError: Js.Promise.error => firebaseError = "%identity";
How can I add extra check to be sure the code
property exists in the error ?