diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index 5a7fdcd1767..1deb5a5073f 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -193,6 +193,9 @@ async def trace_action(hass, script_run, stop, variables): try: yield trace_element + except _StopScript as ex: + trace_element.set_error(ex.__cause__ or ex) + raise ex except Exception as ex: trace_element.set_error(ex) raise ex diff --git a/tests/helpers/test_script.py b/tests/helpers/test_script.py index a0207edcbdd..2045f8cdbbc 100644 --- a/tests/helpers/test_script.py +++ b/tests/helpers/test_script.py @@ -622,7 +622,7 @@ async def test_delay_template_invalid(hass, caplog): assert_action_trace( { "0": [{"result": {"event": "test_event", "event_data": {}}}], - "1": [{"error_type": script._StopScript}], + "1": [{"error_type": vol.MultipleInvalid}], }, expected_script_execution="aborted", ) @@ -683,7 +683,7 @@ async def test_delay_template_complex_invalid(hass, caplog): assert_action_trace( { "0": [{"result": {"event": "test_event", "event_data": {}}}], - "1": [{"error_type": script._StopScript}], + "1": [{"error_type": vol.MultipleInvalid}], }, expected_script_execution="aborted", ) @@ -1138,7 +1138,7 @@ async def test_wait_continue_on_timeout( } if continue_on_timeout is False: expected_trace["0"][0]["result"]["timeout"] = True - expected_trace["0"][0]["error_type"] = script._StopScript + expected_trace["0"][0]["error_type"] = asyncio.TimeoutError expected_script_execution = "aborted" else: expected_trace["1"] = [