Catch Error when MetaMask cancels authentication

I use the useMoralis hook to attempt an authenticate call. How do I catch the error thrown by MetaMask when the user presses cancel instead of sign? The error message: MetaMask Message Signature: User denied message signature.

I can catch the error in a try block when I use Moralis.Web3.authenticate() but the error is not caught when I use the authenticate hook.

1 Like

Would also love to know this!

it should work in a try catch

Tried that, but no success unfortunately

You try this way then.

    signingMessage: "Login",
    onSuccess: (user) => console.log(user),
    onError: (err) => console.log(err)
1 Like