Skip to content

Commit

Permalink
fix(core): handle unexpected user unique identifier error (#6902)
Browse files Browse the repository at this point in the history
handle unexpected user unqque identifier violation error
  • Loading branch information
simeng-li authored Dec 24, 2024
1 parent e312a98 commit ea5a62b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/core/src/middleware/koa-slonik-error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ export default function koaSlonikErrorHandler<StateT, ContextT>(): Middleware<St
status: 422,
});
}

if (error.constraint === 'users__username') {
throw new RequestError({
code: 'user.username_already_in_use',
status: 422,
});
}

if (error.constraint === 'users__primary_email') {
throw new RequestError({
code: 'user.email_already_in_use',
status: 422,
});
}

if (error.constraint === 'users__primary_phone') {
throw new RequestError({
code: 'user.phone_already_in_use',
status: 422,
});
}
}

if (error instanceof CheckIntegrityConstraintViolationError) {
Expand Down

0 comments on commit ea5a62b

Please sign in to comment.