deepkit-framework
deepkit-framework copied to clipboard
Improve errors for missing or misconfigured configuration options
Currently the errors are pretty raw and useful mostly to developers:
ConfigurationInvalidError: Configuration for module root is invalid. Make sure the module is correctly configured. Error: redisPort(required): Required value is undefined
A robust configuration system should report:
- locations (environment variables or config files) it tried to search if the value is missing
- reporting on the config value that needs to be added, if missing (exact variable name, including prefix)
- if validation failed, inform the user what is expected and what is the current value
Basically, a person non-familiar with the codebase should be able to operate a service that's using Deepkit's configuration system.
An example improved error could say:
Required redisHost config variable is missing. Expected CC_REDIS_HOST environment variable to be set. Looked for variables inside '.env'.