fix(modules): Fix miss leading provider resolution error (#10900)

FIXES SUP-560

**What**
Currently, no matter the error when looking for a provider to exists in the container we are throwing a normalized error stating that the provider does not exists in the container. The issue is that the first initialization of the provider occurs the first time we resolve it, and the error can be that the provider failed to be instanciated for any reason. 

In this pr, we are explicitly checking for the error to be an awilix resolution error to throw the classic error and otherwise we provide the issue why the provider failed to be resolved.
This commit is contained in:
Adrien de Peretti
2025-01-10 02:16:33 +01:00
committed by GitHub
parent 44706ef03b
commit c490e08142
6 changed files with 48 additions and 25 deletions

View File

@@ -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)
}
}