uleroboticsgroup / yasmin

YASMIN (Yet Another State MachINe)
GNU General Public License v3.0
130 stars 25 forks source link

Outcomes not matching exception raises TypeError #10

Closed lars-nagel closed 9 months ago

lars-nagel commented 9 months ago

Observed Behavior

It seems that the exception in yasmin/yasmin/state.py can trigger a TypeError instead of displaying the non-matching outcomes:

File "/home/user/ros2_ws/install/yasmin/lib/python3.8/site-packages/yasmin/state.py", line 39, in __call__
    outcome = self.execute(blackboard)
  File "/home/user/ros2_ws/install/yasmin/lib/python3.8/site-packages/yasmin/state_machine.py", line 73, in execute
    outcome = state["state"](blackboard)
  File "/home/user/ros2_ws/install/yasmin/lib/python3.8/site-packages/yasmin/state.py", line 42, in __call__
    raise Exception("Outcome " + outcome + " does not belong")
TypeError: can only concatenate str (not "NoneType") to str

Expected Behavior

Exception highlights non-matching outcome names.

mgonzs13 commented 9 months ago

Thanks for the feedback @lars-nagel. I suppose you are not returning an outcome. I have fixed the TypeError but I may treat the NoneType better in the future.