You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using a _can_trigger: If a prepare callback raises an Exception, this exception gets propangated to the calling code even if you define an on_exception callback.
Minimal working example
fromtransitions.coreimportMachineclassAmp:
def__init__(self):
self._external_resource: None|str=Noneself.machine=Machine(
self,
send_event=True,
states=[
"silent",
"loud",
],
transitions=[
{
"trigger": "turn_up",
"source": "silent",
"dest": "loud",
"prepare": "fetch_external_resource",
# "conditions": "is_external_resource_ready",
},
],
initial="silent",
on_exception="on_exception",
)
deffetch_external_resource(self, event):
print("Refresh something..")
self._external_resource="something"# but this can failraiseValueError("Something went wrong")
defon_exception(self, event):
print(f"Handling exception correctly {event.error=!r}")
amp=Amp()
amp.turn_up()
print (f"State is still {amp.state}")
try:
amp.may_turn_up()
exceptValueError:
print("An exception got raised altough we defined on_exception")
Expected behavior
The on_exception callback gets called when you use may_turn_up()? At least thats what I would expect.
The text was updated successfully, but these errors were encountered:
Describe the bug
When using a _can_trigger: If a
prepare
callback raises an Exception, this exception gets propangated to the calling code even if you define anon_exception
callback.Minimal working example
Expected behavior
The
on_exception
callback gets called when you use may_turn_up()? At least thats what I would expect.The text was updated successfully, but these errors were encountered: