mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Refine scene context error handling
This commit is contained in:
parent
b01560fd29
commit
25deca8f39
2 changed files with 8 additions and 4 deletions
|
|
@ -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__,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue