From 60b8f7100b92dbef4d5863605b729f0a018b00f1 Mon Sep 17 00:00:00 2001 From: Emmanuelle Bonnemay Date: Thu, 14 Nov 2024 14:00:34 +0100 Subject: [PATCH] refactor(api): keep error type "AlreadyRegisteredEmailError" in sco context --- .../create-and-reconcile-user-to-organization-learner.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/lib/domain/usecases/create-and-reconcile-user-to-organization-learner.js b/api/lib/domain/usecases/create-and-reconcile-user-to-organization-learner.js index ca953d85101..c6aba470a1e 100644 --- a/api/lib/domain/usecases/create-and-reconcile-user-to-organization-learner.js +++ b/api/lib/domain/usecases/create-and-reconcile-user-to-organization-learner.js @@ -12,6 +12,7 @@ import { OrganizationLearnerAlreadyLinkedToUserError, } from '../../../src/shared/domain/errors.js'; import { urlBuilder } from '../../../src/shared/infrastructure/utils/url-builder.js'; +import { InvalidOrAlreadyUsedEmailError } from '../../../src/identity-access-management/domain/errors.js'; const createAndReconcileUserToOrganizationLearner = async function ({ campaignCode, @@ -119,6 +120,9 @@ function _createDomainUser(userAttributes) { } function _manageEmailAvailabilityError(error) { + if (error instanceof InvalidOrAlreadyUsedEmailError) { + error = new AlreadyRegisteredEmailError(); + } return _manageError( error, AlreadyRegisteredEmailError,