Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Question: Handling errors in response #78

Open
mrcasablr opened this issue Jun 2, 2021 · 3 comments
Open

Question: Handling errors in response #78

mrcasablr opened this issue Jun 2, 2021 · 3 comments

Comments

@mrcasablr
Copy link

Hello!

Thank you for the SDK and the hasura-backend-plus project, this has made writing new applications for user management sure simple.

I was wondering how errors are handled when using the sdk? I do not see any error examples in the documentation. Specifically, login errors or registration errors for various conditions (incorrect password, user exists.. and such)

@cezarneaga
Copy link

Hi there,
was about to post an issue re this. the response for all the auth methods need to be expanded imo. atm they are not allowing a nice handling of the error states. the messages are not exposed to the client. i can see them on the server but they should trickle down to client too.

what do you think @elitan ?

Best,
Cezar

@elitan
Copy link
Contributor

elitan commented Jul 14, 2021

Sounds reasonable. Do you have a good example of where this is not the case right now? so I get a better understanding.

@buzinas
Copy link

buzinas commented Aug 22, 2021

You can find the error message on error.response, eg:

try {
  await login({ email, password })
catch (err) {
  showError(err.response.data) // data is an object with `message` and other fields
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants