mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 08:17:08 +00:00
Improve vol.Invalid handling (#120480)
This commit is contained in:
parent
ec2f98d075
commit
0bc597f8c7
@ -47,7 +47,7 @@ class InvalidBlueprint(BlueprintWithNameException):
|
|||||||
domain: str | None,
|
domain: str | None,
|
||||||
blueprint_name: str | None,
|
blueprint_name: str | None,
|
||||||
blueprint_data: Any,
|
blueprint_data: Any,
|
||||||
msg_or_exc: vol.Invalid,
|
msg_or_exc: str | vol.Invalid,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize an invalid blueprint error."""
|
"""Initialize an invalid blueprint error."""
|
||||||
if isinstance(msg_or_exc, vol.Invalid):
|
if isinstance(msg_or_exc, vol.Invalid):
|
||||||
|
@ -70,11 +70,11 @@ class LogbookView(HomeAssistantView):
|
|||||||
if entity_ids_str := request.query.get("entity"):
|
if entity_ids_str := request.query.get("entity"):
|
||||||
try:
|
try:
|
||||||
entity_ids = cv.entity_ids(entity_ids_str)
|
entity_ids = cv.entity_ids(entity_ids_str)
|
||||||
except vol.Invalid:
|
except vol.Invalid as ex:
|
||||||
raise InvalidEntityFormatError(
|
raise InvalidEntityFormatError(
|
||||||
f"Invalid entity id(s) encountered: {entity_ids_str}. "
|
f"Invalid entity id(s) encountered: {entity_ids_str}. "
|
||||||
"Format should be <domain>.<object_id>"
|
"Format should be <domain>.<object_id>"
|
||||||
) from vol.Invalid
|
) from ex
|
||||||
else:
|
else:
|
||||||
entity_ids = None
|
entity_ids = None
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ class SetupEntity(Protocol):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_handle_schema_error(
|
def async_handle_schema_error(
|
||||||
discovery_payload: MQTTDiscoveryPayload, err: vol.MultipleInvalid
|
discovery_payload: MQTTDiscoveryPayload, err: vol.Invalid
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Help handling schema errors on MQTT discovery messages."""
|
"""Help handling schema errors on MQTT discovery messages."""
|
||||||
discovery_topic: str = discovery_payload.discovery_data[ATTR_DISCOVERY_TOPIC]
|
discovery_topic: str = discovery_payload.discovery_data[ATTR_DISCOVERY_TOPIC]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user