diff --git a/src/isar/state_machine/states/monitor.py b/src/isar/state_machine/states/monitor.py index 1aea3b63..0c46a7fb 100644 --- a/src/isar/state_machine/states/monitor.py +++ b/src/isar/state_machine/states/monitor.py @@ -17,6 +17,7 @@ RobotException, RobotRetrieveInspectionException, RobotTaskStatusException, + RobotCommunicationException, ) from robot_interface.models.inspection.inspection import Inspection from robot_interface.models.mission.mission import Mission @@ -75,8 +76,11 @@ def _run(self) -> None: time.sleep(self.state_machine.sleep_time) continue - except RobotCommunicationTimeoutException as e: - task_failed: bool = self._handle_communication_timeout(e) + except ( + RobotCommunicationTimeoutException, + RobotCommunicationException, + ) as e: + task_failed: bool = self._handle_communication_retry(e) if task_failed: status = TaskStatus.Failed else: @@ -210,8 +214,8 @@ def _set_error_message(self, e: RobotException) -> None: ) self.state_machine.current_task.error_message = error_message - def _handle_communication_timeout( - self, e: RobotCommunicationTimeoutException + def _handle_communication_retry( + self, e: Union[RobotCommunicationTimeoutException, RobotCommunicationException] ) -> bool: self.state_machine.current_mission.error_message = ErrorMessage( error_reason=e.error_reason, error_description=e.error_description diff --git a/src/robot_interface/models/exceptions/robot_exceptions.py b/src/robot_interface/models/exceptions/robot_exceptions.py index 1cbf9c96..f3c50e32 100644 --- a/src/robot_interface/models/exceptions/robot_exceptions.py +++ b/src/robot_interface/models/exceptions/robot_exceptions.py @@ -43,7 +43,7 @@ def __init__(self, error_reason: ErrorReason, error_description: str): # An exception which should be thrown by the robot package if it is unable to -# communicate with the robot API. +# communicate with the robot API. ISAR will retry the request. class RobotCommunicationException(RobotException): def __init__(self, error_description: str) -> None: super().__init__(