Refine scene context error handling

This commit is contained in:
latand 2026-02-10 22:10:11 +02:00
parent b01560fd29
commit 25deca8f39
2 changed files with 8 additions and 4 deletions

View file

@ -251,10 +251,14 @@ class SceneHandlerWrapper:
try:
state: FSMContext = kwargs["state"]
scenes: ScenesManager = kwargs["scenes"]
event_update: Update = kwargs["event_update"]
except KeyError:
msg = "Scene context is not available. Ensure FSM is enabled and pipeline is intact."
except KeyError as error:
missing_key = error.args[0]
msg = (
f"Scene context key {missing_key!r} is not available. "
"Ensure FSM is enabled and pipeline is intact."
)
raise SceneException(msg) from None
event_update: Update = kwargs["event_update"]
scene = self.scene(
wizard=SceneWizard(
scene_config=self.scene.__scene_config__,

View file

@ -333,7 +333,7 @@ class TestSceneHandlerWrapper:
with pytest.raises(
SceneException,
match="Scene context is not available. Ensure FSM is enabled and pipeline is intact.",
match="Scene context key 'state' is not available. Ensure FSM is enabled and pipeline is intact.",
):
await scene_handler_wrapper(event_update_mock, event_update=event_update_mock)