Skip to content

Commit

Permalink
fix(modules): Fix miss leading provider resolution error
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien2p committed Jan 9, 2025
1 parent 28febfc commit 5d24571
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 24 deletions.
14 changes: 10 additions & 4 deletions packages/modules/auth/src/services/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ 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)
}
}
Expand Down
14 changes: 10 additions & 4 deletions packages/modules/fulfillment/src/services/fulfillment-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ 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)
}
}
Expand Down
14 changes: 10 additions & 4 deletions packages/modules/locking/src/services/locking-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ 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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ 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)
}
}
Expand Down
19 changes: 11 additions & 8 deletions packages/modules/payment/src/services/payment-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ 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.
`

// Ensure that the logger captures the actual error
this.#logger.error(e)
} 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)
}

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)
}
Expand Down

0 comments on commit 5d24571

Please sign in to comment.