From fdb94546176d8d2fbbcb2db8d58b320de13ee992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Gonz=C3=A1lez=20Santamarta?= Date: Sun, 27 Oct 2024 12:35:42 +0100 Subject: [PATCH] comments for terminal outcomes --- yasmin/yasmin/state_machine.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yasmin/yasmin/state_machine.py b/yasmin/yasmin/state_machine.py index bb25d78..d24f593 100644 --- a/yasmin/yasmin/state_machine.py +++ b/yasmin/yasmin/state_machine.py @@ -112,19 +112,23 @@ def validate(self, raise_exception: bool = True) -> str: # check terminal outcomes for the state machine terminal_outcomes = set(terminal_outcomes) + + # check if all state machine outcomes are in the terminal outcomes for o in self.get_outcomes(): if o not in terminal_outcomes: errors += f"\n\tTarget outcome '{o}' not registered in transitions" + # check if all terminal outcomes are states or state machine outcomes for o in terminal_outcomes: if o not in set(list(self._states.keys()) + self.get_outcomes()): errors += f"\n\tState machine outcome '{o}' not registered as outcome neither state" if errors: + errors = f"{'*' * 100}\nState machine failed validation check:{errors}\n\n\tAvailable states: {list(self._states.keys())}\n{'*' * 100}" - if raise_exception and errors: - raise Exception(errors) + if raise_exception: + raise Exception(errors) return errors