Node-Auth error codes

Hi everybody so i’m having a little bit problem with implemeting Auth0 with my NestJS backend.
I want that my backend has an api endpoint for handle the Auth0 signup. The problem is that Auth0 doesn’t have any specific Error code. So i’m having few troubles about creating an a-doc exceptions for handle all the possible cases.

1 Like

Hi @Enkosz Welcome to Auth0 Community. Could tyou clarify what do you mean by that? Are you signing up user by creating them yourself via backend? Or are the users signing up via your universal login page? If you could provide more details on what method/endpoint is being used to signup user we might be able to provide proper suggestion for you.

Ok so i will explain the stack that i’m using.
I’m building an SPA + API application:
Frontend: VueJS
Backend: NestJS
So how my signup process works? I’m using a my own signin and signup page in the frontend and when a user want to signup he sends a POST request to my backend that handles in few steps:

  1. Send request to Auth0 by creating an user (using the create user auth0 endpoint)
  2. Create a local user entity in my local database saving the created auth0 user id reference

I’m doing this because i need a more complex validation system and for other reason.
I would like to know what is the best way to handle the Auth0 exception created by the backend call to Auth0. For example if a user already exist is there any Unique error code to identify it?
I need it because i need to handle the errors cases in different ways

Yes, the api will return http status code 409 The user already exists. Check the response messages under endpoint docs here https://auth0.com/docs/api/management/v2#!/Users/post_users

But i mean is there any unique code like “USER_ALREADY_EXIST” because i debugged the response and all i can see is a message.

For example this is the response:

{
“statusCode”: 409,
“error”: “Conflict”,
“message”: “The user already exists.”,
“errorCode”: “auth0_idp_error”
}

I would expect more unique like the errorCode instead of the message. But as i can see the errorCode is the same for other errors

I see, thanks for clarifying that. Yes, as you expected there is no support for that in node sdk yet. Feel free to report your requirement via node sdk github issues https://github.com/auth0/node-auth0/issues

For now you will have to rely on statusCode as node sdk is a very light wrapper around management api endpoints.

1 Like

Thank you! Then i will try to give some help with the wrapper if i can!

1 Like