Improve example raising ServiceValidationError (#1991)

This commit is contained in:
Jan Bouwhuis 2023-11-25 08:26:59 +01:00 committed by GitHub
parent 6343922de2
commit 2456fcc659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -184,15 +184,15 @@ async def async_select_index(hass: HomeAssistant, index: int) -> None:
"""Setup the config entry for my device."""
try:
check_index(index)
except ValueError as ex:
except ValueError as exc:
raise ServiceValidationError(
message,
str(exc),
translation_domain=DOMAIN,
translation_key="invalid_index",
translation_placeholders={
"index": index,
},
) from ex
) from exc
```