Skip to content

Commit

Permalink
Merge pull request #398 from chaynHQ/develop
Browse files Browse the repository at this point in the history
Merge Develop onto Main
  • Loading branch information
annarhughes committed Feb 16, 2024
2 parents b9f4371 + 31e2b8f commit 2041fbf
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ export class UserService {
this.logger.error(`Create user: Error creating firebase user - ${email}: ${err}`);
throw err;
} else {
this.logger.warn(
this.logger.error(
`Create user: Unable to create firebase user as user already exists: ${email}`,
);
throw new HttpException(CREATE_USER_EMAIL_ALREADY_EXISTS, HttpStatus.BAD_REQUEST);
}
}

Expand Down Expand Up @@ -141,19 +142,6 @@ export class UserService {

return formattedUserObject;
} catch (error) {
const userAlreadyExists = (err) =>
err.message.includes('already exists') ||
err.message.includes('UQ_e12875dfb3b1d92d7d7c5377e22') ||
err.message.includes(
'duplicate key value violates unique constraint "UQ_905432b2c46bdcfe1a0dd3cdeff"',
);
if (userAlreadyExists(error)) {
this.logger.warn(`Create user: User already exists ${email}`);
throw new HttpException(CREATE_USER_EMAIL_ALREADY_EXISTS, HttpStatus.CONFLICT);
}
if (error.code === '23505') {
throw new HttpException(error.detail, HttpStatus.CONFLICT);
}
this.logger.error(`Create user: Error creating user ${email}: ${error}`);
throw error;
}
Expand Down

0 comments on commit 2041fbf

Please sign in to comment.