mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
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 routine
This commit is contained in:
parent
79d3f533a9
commit
c812176e94
@ -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…
x
Reference in New Issue
Block a user