Skip to content

Commit

Permalink
exception inside concurrency will get re-thrown to preempt behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
David Conner committed Sep 26, 2024
1 parent 39beaaa commit c57c7fd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions flexbe_core/flexbe_core/core/concurrency_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
It synchronizes its current state with the mirror and supports some control mechanisms.
"""
from flexbe_core.core.event_state import EventState
from flexbe_core.core.exceptions import StateError, StateMachineError, UserDataError
from flexbe_core.core.lockable_state_machine import LockableStateMachine
from flexbe_core.core.operatable_state_machine import OperatableStateMachine
from flexbe_core.core.preemptable_state import PreemptableState
Expand Down Expand Up @@ -259,11 +260,17 @@ def _execute_single_state(self, state, force_exit=False):
else:
result = state.execute(userdata) # This is call on_exit if necessary
except Exception as exc: # pylint: disable=W0703
# catch any exception and log here, but re-raise to preempt behavior
result = None
self._last_exception = exc
Logger.logerr('ConcurrencyContainer: Failed to execute state %s:\n%s' % (self.current_state_label, str(exc)))
import traceback # pylint: disable=C0415
Logger.localinfo(traceback.format_exc().replace('%', '%%'))
if isinstance(exc, (StateError, StateMachineError, UserDataError)):
self._last_exception = exc
else:
self._last_exception = StateError(str(exc))
raise self._last_exception
return result

def on_enter(self, userdata): # pylint: disable=W0613
Expand Down

0 comments on commit c57c7fd

Please sign in to comment.