Include _StopScript.__cause__ in trace (#50441)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Erik Montnemery 2021-05-12 07:27:11 +02:00 committed by GitHub
parent 5ed252ebfa
commit b35f229674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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"] = [