Improve config validation error message
This commit is contained in:
parent
e67729b2f4
commit
e40908d67c
3 changed files with 22 additions and 9 deletions
|
@ -146,7 +146,7 @@ def time_period_str(value):
|
|||
time_period = vol.Any(time_period_str, timedelta, time_period_dict)
|
||||
|
||||
|
||||
def log_exception(logger, ex, domain):
|
||||
def log_exception(logger, ex, domain, config):
|
||||
"""Generate log exception for config validation."""
|
||||
message = 'Invalid config for [{}]: '.format(domain)
|
||||
if 'extra keys not allowed' in ex.error_message:
|
||||
|
@ -154,7 +154,12 @@ def log_exception(logger, ex, domain):
|
|||
.format(ex.path[-1], domain, domain,
|
||||
'->'.join('%s' % m for m in ex.path))
|
||||
else:
|
||||
message += ex.error_message
|
||||
message += str(ex)
|
||||
|
||||
if hasattr(config, '__line__'):
|
||||
message += " (See {}:{})".format(config.__config_file__,
|
||||
config.__line__ or '?')
|
||||
|
||||
logger.error(message)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue