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
FysomErrors raised from FysomGlobal contain the same information as those raised from Fysom. FysomError instances need to include an attribute ('obj' ?) that contains the object instance of the FysomMixin from which the exception is raised. Custom handlers (try..except FysomError as err:) can then format more helpful debugging information.
This should be a straightforward fix by adding an instance= kwarg to the FysomError constructor. And, there are only a very few places in FysomGlobal where the error is raised.
The text was updated successfully, but these errors were encountered:
Here are the changes to implement this issue:
--- a/src/main/python/fysom/init.py
+++ b/src/main/python/fysom/init.py
@@ -58,9 +58,10 @@ class FysomError(Exception):
in case of sharing event data.
'''
class Canceled(FysomError):
@@ -586,7 +587,7 @@ class FysomGlobal(object):
if not self.can(obj, event):
raise FysomError(
'event %s inappropriate in current state %s'
% (event, self.current(obj)))
% (event, self.current(obj)), instance=obj)
# Prepare the event object with all the meta data to pas through.
# On event occurrence, source will always be the current state.
@@ -612,14 +613,14 @@ class FysomGlobal(object):
raise Canceled(
'Cannot trigger event {0} because the {1} '
'condition not returns {2}'.format(
event, cond, target), e
event, cond, target), e, instance=obj
)
# try to trigger the before event, unless it gets cancelled.
if self._before_event(obj, e) is False:
raise Canceled(
'Cannot trigger event {0} because the onbefore{0} '
'handler returns False'.format(event), e)
'handler returns False'.format(event), e, instance=obj)
# wraps the activities that must constitute a single transaction
if self.current(obj) != e.dst:
@@ -717,5 +718,5 @@ class FysomGlobal(object):
def trigger(self, obj, event, *args, **kwargs):
if not hasattr(self, event):
raise FysomError(
"There isn't any event registered as %s" % event)
"There isn't any event registered as %s" % event, instance=obj)
FysomErrors raised from FysomGlobal contain the same information as those raised from Fysom. FysomError instances need to include an attribute ('obj' ?) that contains the object instance of the FysomMixin from which the exception is raised. Custom handlers (try..except FysomError as err:) can then format more helpful debugging information.
This should be a straightforward fix by adding an instance= kwarg to the FysomError constructor. And, there are only a very few places in FysomGlobal where the error is raised.
The text was updated successfully, but these errors were encountered: