From 7fc230f227691ed788688b837e8d34a144d70dbb Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Wed, 22 May 2024 10:13:55 -0400 Subject: [PATCH] chore(api): raise EnumeratedError for failed status check (#15241) If you did a motor_engaged() query and the node didn't respond, you'd get a KeyError wrapped in a 4000 error, which isn't correct or useful. Make that a 1000 error instead. --- .../hardware_control/backends/ot3controller.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/src/opentrons/hardware_control/backends/ot3controller.py b/api/src/opentrons/hardware_control/backends/ot3controller.py index 4dd1e814b8e..1b90e086dca 100644 --- a/api/src/opentrons/hardware_control/backends/ot3controller.py +++ b/api/src/opentrons/hardware_control/backends/ot3controller.py @@ -192,6 +192,8 @@ FirmwareUpdateRequiredError, FailedGripperPickupError, LiquidNotFoundError, + CommunicationError, + PythonException, ) from .subsystem_manager import SubsystemManager @@ -1186,7 +1188,14 @@ async def update_engaged_axes(self) -> None: async def is_motor_engaged(self, axis: Axis) -> bool: node = axis_to_node(axis) result = await get_motor_enabled(self._messenger, {node}) - engaged = result[node] + try: + engaged = result[node] + except KeyError as ke: + raise CommunicationError( + message=f"No response from {node.name} for motor engagement query", + detail={"node": node.name}, + wrapping=[PythonException(ke)], + ) from ke self._engaged_axes.update({axis: engaged}) return engaged