Correct keyerror exception. (#52150)

This commit is contained in:
jan iversen 2021-06-26 20:09:53 +02:00 committed by GitHub
parent 5687ced7b3
commit c558c77413
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,10 +40,10 @@ def sensor_schema_validator(config):
structure = (
f">{DEFAULT_STRUCT_FORMAT[config[CONF_DATA_TYPE]][config[CONF_COUNT]]}"
)
except KeyError:
except KeyError as key:
raise vol.Invalid(
f"Unable to detect data type for {config[CONF_NAME]} sensor, try a custom type"
) from KeyError
) from key
else:
structure = config.get(CONF_STRUCTURE)