diff --git a/packages/modules/auth/integration-tests/__tests__/auth-module-service/index.spec.ts b/packages/modules/auth/integration-tests/__tests__/auth-module-service/index.spec.ts index 5f53ed9f12..cf185e4198 100644 --- a/packages/modules/auth/integration-tests/__tests__/auth-module-service/index.spec.ts +++ b/packages/modules/auth/integration-tests/__tests__/auth-module-service/index.spec.ts @@ -84,8 +84,9 @@ moduleIntegrationTestRunner({ expect(err).toEqual({ success: false, - error: - "\n Unable to retrieve the auth provider with id: facebook\n Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.\n ", + error: ` +Unable to retrieve the auth provider with id: facebook +Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.`, }) }) diff --git a/packages/modules/auth/src/services/auth-provider.ts b/packages/modules/auth/src/services/auth-provider.ts index 193d9f412f..f919faba84 100644 --- a/packages/modules/auth/src/services/auth-provider.ts +++ b/packages/modules/auth/src/services/auth-provider.ts @@ -31,11 +31,16 @@ export default class AuthProviderService { try { return this.dependencies[`${AuthProviderRegistrationPrefix}${providerId}`] } catch (err) { - const errMessage = ` - Unable to retrieve the auth provider with id: ${providerId} - Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file. - ` + if (err.name === "AwilixResolutionError") { + const errMessage = ` +Unable to retrieve the auth provider with id: ${providerId} +Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.` + throw new Error(errMessage) + } + + const errMessage = `Unable to retrieve the auth provider with id: ${providerId}, the following error occurred: ${err.message}` this.#logger.error(errMessage) + throw new Error(errMessage) } } diff --git a/packages/modules/fulfillment/src/services/fulfillment-provider.ts b/packages/modules/fulfillment/src/services/fulfillment-provider.ts index f667ed2945..104410fc25 100644 --- a/packages/modules/fulfillment/src/services/fulfillment-provider.ts +++ b/packages/modules/fulfillment/src/services/fulfillment-provider.ts @@ -62,11 +62,16 @@ export default class FulfillmentProviderService extends ModulesSdkUtils.MedusaIn try { return this.__container__[`fp_${providerId}`] } catch (err) { - const errMessage = ` - Unable to retrieve the fulfillment provider with id: ${providerId} - Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file. - ` + if (err.name === "AwilixResolutionError") { + const errMessage = ` +Unable to retrieve the fulfillment provider with id: ${providerId} +Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.` + throw new Error(errMessage) + } + + const errMessage = `Unable to retrieve the fulfillment provider with id: ${providerId}, the following error occurred: ${err.message}` this.#logger.error(errMessage) + throw new Error(errMessage) } } diff --git a/packages/modules/locking/src/services/locking-provider.ts b/packages/modules/locking/src/services/locking-provider.ts index d876a51ffe..75e972dc70 100644 --- a/packages/modules/locking/src/services/locking-provider.ts +++ b/packages/modules/locking/src/services/locking-provider.ts @@ -40,11 +40,16 @@ export default class LockingProviderService { `${LockingProviderRegistrationPrefix}${providerId}` ] } catch (err) { - const errMessage = ` - Unable to retrieve the locking provider with id: ${providerId} - Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file. - ` + if (err.name === "AwilixResolutionError") { + const errMessage = ` + Unable to retrieve the locking provider with id: ${providerId} +Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.` + throw new Error(errMessage) + } + + const errMessage = `Unable to retrieve the locking provider with id: ${providerId}, the following error occurred: ${err.message}` this.#logger.error(errMessage) + throw new Error(errMessage) } } diff --git a/packages/modules/notification/src/services/notification-provider.ts b/packages/modules/notification/src/services/notification-provider.ts index 26fdb3f81b..54ae334856 100644 --- a/packages/modules/notification/src/services/notification-provider.ts +++ b/packages/modules/notification/src/services/notification-provider.ts @@ -54,11 +54,16 @@ export default class NotificationProviderService extends ModulesSdkUtils.MedusaI `${NotificationProviderRegistrationPrefix}${providerId}` ] } catch (err) { - const errMessage = ` - Unable to retrieve the notification provider with id: ${providerId} - Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file. - ` + if (err.name === "AwilixResolutionError") { + const errMessage = ` +Unable to retrieve the notification provider with id: ${providerId} +Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.` + throw new Error(errMessage) + } + + const errMessage = `Unable to retrieve the notification provider with id: ${providerId}, the following error occurred: ${err.message}` this.#logger.error(errMessage) + throw new Error(errMessage) } } diff --git a/packages/modules/payment/src/services/payment-provider.ts b/packages/modules/payment/src/services/payment-provider.ts index e996dd30ae..bfb8fc6a67 100644 --- a/packages/modules/payment/src/services/payment-provider.ts +++ b/packages/modules/payment/src/services/payment-provider.ts @@ -42,14 +42,16 @@ export default class PaymentProviderService extends ModulesSdkUtils.MedusaIntern retrieveProvider(providerId: string): IPaymentProvider { try { return this.__container__[providerId] as IPaymentProvider - } catch (e) { - const errMessage = ` - Unable to retrieve the payment provider with id: ${providerId} - Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file. - ` + } catch (err) { + if (err.name === "AwilixResolutionError") { + const errMessage = ` +Unable to retrieve the payment provider with id: ${providerId} +Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.` + throw new Error(errMessage) + } - // Ensure that the logger captures the actual error - this.#logger.error(e) + const errMessage = `Unable to retrieve the payment provider with id: ${providerId}, the following error occurred: ${err.message}` + this.#logger.error(errMessage) throw new Error(errMessage) }