Unique constraint error while registering user with existing data
arifszn opened this issue · 0 comments
arifszn commented
If a user with username x
or email x@example.com
is already registered, while registering with the same input, it throws 500 internal server error
.
{
"error": {
"statusCode": 500,
"message": "ER_DUP_ENTRY: Duplicate entry 'x' for key 'users.username'",
"errorName": "QueryFailedError",
"path": "/api/v1/auth/register",
"requestId": "280f8680-1642-4518-9b51-c3ab57010e00",
"timestamp": "2022-06-27T12:18:36.999Z"
}
}
Handling while trying to register with existing data and throwing 400 Bad request
would be more suitable instead of 500
.