Fix the line reference in config error message (#20743)
* Fix the line reference in config error message * Fix platform config validation * Fix test * Handle error in error handling routinepull/20794/head
parent
cfa03a408e
commit
a8b4467763
|
@ -446,7 +446,11 @@ def _format_config_error(ex: vol.Invalid, domain: str, config: Dict) -> str:
|
|||
else:
|
||||
message += '{}.'.format(humanize_error(config, ex))
|
||||
|
||||
domain_config = config.get(domain, config)
|
||||
try:
|
||||
domain_config = config.get(domain, config)
|
||||
except AttributeError:
|
||||
domain_config = config
|
||||
|
||||
message += " (See {}, line {}). ".format(
|
||||
getattr(domain_config, '__config_file__', '?'),
|
||||
getattr(domain_config, '__line__', '?'))
|
||||
|
@ -759,7 +763,7 @@ def async_process_component_config(
|
|||
p_validated = component.PLATFORM_SCHEMA( # type: ignore
|
||||
p_config)
|
||||
except vol.Invalid as ex:
|
||||
async_log_exception(ex, domain, config, hass)
|
||||
async_log_exception(ex, domain, p_config, hass)
|
||||
continue
|
||||
|
||||
# Not all platform components follow same pattern for platforms
|
||||
|
@ -779,10 +783,10 @@ def async_process_component_config(
|
|||
# pylint: disable=no-member
|
||||
try:
|
||||
p_validated = platform.PLATFORM_SCHEMA( # type: ignore
|
||||
p_validated)
|
||||
p_config)
|
||||
except vol.Invalid as ex:
|
||||
async_log_exception(ex, '{}.{}'.format(domain, p_name),
|
||||
p_validated, hass)
|
||||
p_config, hass)
|
||||
continue
|
||||
|
||||
platforms.append(p_validated)
|
||||
|
|
Loading…
Reference in New Issue