From c87b4df4ef7d138d80768951a06107c3b66f46ab Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 12 Dec 2019 08:08:43 +0100 Subject: automata.State: improve error message on missing transition --- lib/automata.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/automata.py b/lib/automata.py index 8e889aa..db7caf0 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -142,7 +142,10 @@ class State: :param transition_name: transition name :returns: `Transition` object """ - return self.outgoing_transitions[transition_name] + try: + return self.outgoing_transitions[transition_name] + except KeyError: + raise ValueError('State {} has no outgoing transition called {}'.format(self.name, transition_name)) from None def has_interrupt_transitions(self) -> bool: """Return whether this state has any outgoing interrupt transitions.""" -- cgit v1.2.3