gotrue: Adding error codes to ApiError

Feature request

Is your feature request related to a problem? Please describe.

I am building a website with supabase and the errors that is returned from supabase.auth only contains a general error code 400 and a message in english. This makes the different errors hard to distinguish from eachother.

Example: User tries to create an account but the user is already registered so the error returned from supabase.auth.signUp will be

{ 
  message: "User already registered",
  status: 400
}

Describe the solution you’d like

If the error included a specific error code mapped to particular error then providing a custom message would be easy.

Example:

{ 
  message: "User already registered",
  status: 400,
  errorCode: 1,
}

It would also be really awesome if the error codes was included in the documentation.

Describe alternatives you’ve considered

I’ve considered checking the string value returned in the error but if that would change in the future that would in turn break the application.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 67
  • Comments: 21

Most upvoted comments

+1 for this change, as at this time distinguishing between errors (and translating them to different languages), is completely contingent on parsing the message being returned (and if that message one day got changed, it would break whatever logic we’ve had to build on top of it)

I ran into the same issue and started collecting possible error messages by going through the GoTrue implementation.

I collect the errors for each endpoint in this Google Sheets doc. It’s WIP so everything in this sheet is a little bit messy at the moment.

I also created a npm package that offers an error handler method for each function of GoTrue JS and therefore also Supabase JS.

Over a year later and this has not been addressed. I thought features like this were standard practice.

Such improvement would be great for developer experience, +1 to this idea.

I strongly support this request!
Error codes would facilitate the creation of dictionary data for translation and help with multilingualization.

I am developing an application for Japanese and currently there is no list of error messages, so I am having a hard time creating dictionary data.

Any progress on this would be great help! Is there a way we can contribute ourselves?

+1, Firebase has these standard error codes and it really is essential if you want to, for example, translate the messages

This just made ditch supabase Auth for something else.

Its standard practise to return proper errors.

But till now over a year nothing has been done. There is no proper CURL documentation for us to implement the rest Auth into a SDK ourselves.

Even on the little examples, errors are not treated well. this is a no no for me,shows an unserious company in this aspect

Related to supabase/supabase#12739

+1, it’s hard to use registration/signin manually with react native development using supabase lib, i am a js/ts library user but i would recommend having code status too…

I have already created feature request since Sept but no one have ever response to it

Thought this was industry standard and not something to implement upon request. Any developments on this?