From 6857275a13c4e8172fe3447b8d89ae0b1baf40e6 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Wed, 20 May 2026 11:47:53 +0200 Subject: [PATCH] jfjoch: exception catching. --- src/aare/devices/jfjoch.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/aare/devices/jfjoch.py b/src/aare/devices/jfjoch.py index 8db2bfc3..0d551a4f 100644 --- a/src/aare/devices/jfjoch.py +++ b/src/aare/devices/jfjoch.py @@ -238,12 +238,34 @@ class JFJochWrapper: ) def detector(self) -> jfjoch_client.models.DetectorListElement: - l = self.__api.config_select_detector_get() + try: + l = self.__api.config_select_detector_get() + except Exception as e: + self._raise_jfjoch_error( + f"JFJoch detector configuration retrieval failed: {e}", + error=e, + operation="GET", + endpoint="config_select_detector_get", + ) if len(l.detectors) == 0: - raise Exception("no detectors configured") + raise JFJochCommunicationError( + "JFJoch returned no configured detectors", + operation="GET", + endpoint="config_select_detector_get", + base_url=self.__url, + status_code=None, + ) - return l.detectors[l.current_id] + try: + return l.detectors[l.current_id] + except Exception as e: + self._raise_jfjoch_error( + "JFJoch returned an invalid selected detector entry", + error=e, + operation="GET", + endpoint="config_select_detector_get", + ) def get_diffraction_image(self, image_id: int, wait_between_retries_s: float = 0.1): last_error = None