Send localization info on websocket_api script errors (#104638)
* Send localization info on script errors * Use connection exception hander * Keep HomeAssistantError is unknown_error * Move specific exception handling
This commit is contained in:
parent
7dbaf40f48
commit
efd330f182
6 changed files with 106 additions and 3 deletions
|
@ -778,7 +778,25 @@ async def handle_execute_script(
|
|||
|
||||
context = connection.context(msg)
|
||||
script_obj = Script(hass, script_config, f"{const.DOMAIN} script", const.DOMAIN)
|
||||
script_result = await script_obj.async_run(msg.get("variables"), context=context)
|
||||
try:
|
||||
script_result = await script_obj.async_run(
|
||||
msg.get("variables"), context=context
|
||||
)
|
||||
except ServiceValidationError as err:
|
||||
connection.logger.error(err)
|
||||
connection.logger.debug("", exc_info=err)
|
||||
connection.send_error(
|
||||
msg["id"],
|
||||
const.ERR_SERVICE_VALIDATION_ERROR,
|
||||
str(err),
|
||||
translation_domain=err.translation_domain,
|
||||
translation_key=err.translation_key,
|
||||
translation_placeholders=err.translation_placeholders,
|
||||
)
|
||||
return
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
connection.async_handle_exception(msg, exc)
|
||||
return
|
||||
connection.send_result(
|
||||
msg["id"],
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue