Rewrite config error messages to be more instructive.
Change-Id: I56a34244d13615e79f7b727eee568eadbed403a6
This commit is contained in:
parent
ddf4d9f526
commit
fe9c590bca
|
@ -2,6 +2,7 @@ import os
|
||||||
|
|
||||||
import environ
|
import environ
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from everett import ConfigurationError
|
from everett import ConfigurationError
|
||||||
from everett.manager import ConfigEnvFileEnv, ConfigIniEnv, ConfigManager, ConfigOSEnv, listify
|
from everett.manager import ConfigEnvFileEnv, ConfigIniEnv, ConfigManager, ConfigOSEnv, listify
|
||||||
|
|
||||||
|
@ -73,3 +74,16 @@ class EverettEnviron(environ.Env):
|
||||||
]
|
]
|
||||||
).with_namespace("ara")
|
).with_namespace("ara")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_value(self, var, cast=None, default=environ.Env.NOTSET, parse_default=False):
|
||||||
|
try:
|
||||||
|
return super().get_value(var, cast, default, parse_default)
|
||||||
|
except ImproperlyConfigured as e:
|
||||||
|
# Rewrite the django-environ exception to match our configs better
|
||||||
|
if default is self.NOTSET and str(e) == "Set the {0} environment variable".format(var):
|
||||||
|
error_msg = (
|
||||||
|
"Set the ARA_{0} environment variable or set {1} in the [ara] section "
|
||||||
|
"of your configuration file."
|
||||||
|
).format(var, var.lower())
|
||||||
|
raise ImproperlyConfigured(error_msg)
|
||||||
|
raise
|
||||||
|
|
Loading…
Reference in New Issue