mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 04:50:17 +00:00
Improve error message for invalid key in config (#1975)
* Improve error message for invalid key in config * Refactor log exception in config validation
This commit is contained in:
committed by
Paulus Schoutsen
parent
67f3fcc5cf
commit
21dd8162b3
@@ -14,6 +14,7 @@ import homeassistant.components as core_components
|
||||
import homeassistant.components.group as group
|
||||
import homeassistant.config as config_util
|
||||
import homeassistant.core as core
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.loader as loader
|
||||
import homeassistant.util.dt as date_util
|
||||
import homeassistant.util.location as loc_util
|
||||
@@ -103,7 +104,7 @@ def _setup_component(hass, domain, config):
|
||||
try:
|
||||
config = component.CONFIG_SCHEMA(config)
|
||||
except vol.MultipleInvalid as ex:
|
||||
_LOGGER.error('Invalid config for [%s]: %s', domain, ex)
|
||||
cv.log_exception(_LOGGER, ex, domain)
|
||||
return False
|
||||
|
||||
elif hasattr(component, 'PLATFORM_SCHEMA'):
|
||||
@@ -113,8 +114,7 @@ def _setup_component(hass, domain, config):
|
||||
try:
|
||||
p_validated = component.PLATFORM_SCHEMA(p_config)
|
||||
except vol.MultipleInvalid as ex:
|
||||
_LOGGER.error('Invalid platform config for [%s]: %s. %s',
|
||||
domain, ex, p_config)
|
||||
cv.log_exception(_LOGGER, ex, domain)
|
||||
return False
|
||||
|
||||
# Not all platform components follow same pattern for platforms
|
||||
@@ -135,9 +135,8 @@ def _setup_component(hass, domain, config):
|
||||
try:
|
||||
p_validated = platform.PLATFORM_SCHEMA(p_validated)
|
||||
except vol.MultipleInvalid as ex:
|
||||
_LOGGER.error(
|
||||
'Invalid platform config for [%s.%s]: %s. %s',
|
||||
domain, p_name, ex, p_config)
|
||||
cv.log_exception(_LOGGER, ex, '{}.{}'
|
||||
.format(domain, p_name))
|
||||
return False
|
||||
|
||||
platforms.append(p_validated)
|
||||
@@ -233,7 +232,7 @@ def from_config_dict(config, hass=None, config_dir=None, enable_log=True,
|
||||
process_ha_core_config(hass, config_util.CORE_CONFIG_SCHEMA(
|
||||
config.get(core.DOMAIN, {})))
|
||||
except vol.MultipleInvalid as ex:
|
||||
_LOGGER.error('Invalid config for [homeassistant]: %s', ex)
|
||||
cv.log_exception(_LOGGER, ex, 'homeassistant')
|
||||
return None
|
||||
|
||||
process_ha_config_upgrade(hass)
|
||||
|
||||
Reference in New Issue
Block a user