mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add additional error handling for automation script run (#45613)
This commit is contained in:
parent
5711d61b38
commit
7673f57248
@ -404,6 +404,12 @@ class AutomationEntity(ToggleEntity, RestoreEntity):
|
|||||||
await self.action_script.async_run(
|
await self.action_script.async_run(
|
||||||
variables, trigger_context, started_action
|
variables, trigger_context, started_action
|
||||||
)
|
)
|
||||||
|
except (vol.Invalid, HomeAssistantError) as err:
|
||||||
|
self._logger.error(
|
||||||
|
"Error while executing automation %s: %s",
|
||||||
|
self.entity_id,
|
||||||
|
err,
|
||||||
|
)
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
self._logger.exception("While executing automation %s", self.entity_id)
|
self._logger.exception("While executing automation %s", self.entity_id)
|
||||||
|
|
||||||
|
@ -291,6 +291,9 @@ class _ScriptRun:
|
|||||||
elif isinstance(exception, exceptions.ServiceNotFound):
|
elif isinstance(exception, exceptions.ServiceNotFound):
|
||||||
error_desc = "Service not found"
|
error_desc = "Service not found"
|
||||||
|
|
||||||
|
elif isinstance(exception, exceptions.HomeAssistantError):
|
||||||
|
error_desc = "Error"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
error_desc = "Unexpected error"
|
error_desc = "Unexpected error"
|
||||||
level = _LOG_EXCEPTION
|
level = _LOG_EXCEPTION
|
||||||
|
@ -947,6 +947,7 @@ async def test_automation_with_error_in_script(hass, caplog):
|
|||||||
hass.bus.async_fire("test_event")
|
hass.bus.async_fire("test_event")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert "Service not found" in caplog.text
|
assert "Service not found" in caplog.text
|
||||||
|
assert "Traceback" not in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_automation_with_error_in_script_2(hass, caplog):
|
async def test_automation_with_error_in_script_2(hass, caplog):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user