Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions api/src/opentrons/protocol_engine/execution/command_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ async def execute(self, command_id: str) -> None:
log.debug(
f"Executing {running_command.id}, {running_command.commandType}, {running_command.params}"
)
error_occurred = False
try:
result = await command_impl.execute(
running_command.params # type: ignore[arg-type]
Expand Down Expand Up @@ -191,7 +192,7 @@ async def execute(self, command_id: str) -> None:
type=error_recovery_type,
)
)
await self.capture_error_image(running_command)
error_occurred = True

else:
if isinstance(result, SuccessData):
Expand Down Expand Up @@ -227,6 +228,10 @@ async def execute(self, command_id: str) -> None:
type=error_recovery_type,
)
)
error_occurred = True
finally:
# Handle error image capture if appropriate
if error_occurred:
await self.capture_error_image(running_command)

def cancel_tasks(self, message: str | None = None) -> None:
Expand All @@ -236,7 +241,10 @@ def cancel_tasks(self, message: str | None = None) -> None:
async def capture_error_image(self, running_command: Command) -> None:
"""Capture an image of an error event."""
try:
camera_enablement = await self._camera_provider.get_camera_settings()
camera_enablement = self._state_store.camera.get_enablement_settings()
if camera_enablement is None:
# Utilize the global camera settings
camera_enablement = await self._camera_provider.get_camera_settings()
# Only capture photos of errors if the setting to do so is enabled
if (
camera_enablement.cameraEnabled
Expand Down
Loading