jfjoch: added custom excpetions

This commit is contained in:
2026-03-25 13:24:05 +01:00
parent 98f665370a
commit fbc9890fe4
+32 -4
View File
@@ -3,6 +3,7 @@ import math
import jfjoch_client
from aare.common.beamline import MXBeamline
from aare.common.exception_handler import JFJochCommunicationError
from aare.common.models import DAQStatusModel, FluorescenceSpectrumOutputModel
from aare.common.raster_grid import RasterGridRequest
from aare.common.rotation_scan import RotationScanRequest
@@ -98,7 +99,18 @@ class JFJochWrapper:
detect_ice_rings=True,
xray_fluorescence_spectrum=xrf
)
self.__api.start_post(dataset_settings=dataset_settings)
try:
self.__api.start_post(dataset_settings=dataset_settings)
except Exception as e:
scan_type = "rotation"
if r.screening:
scan_type = "screening"
raise JFJochCommunicationError(
f"JFJoch data collection failed to initialize for {scan_type} scan",
operation="POST",
endpoint="start_post",
base_url=self.__url,
) from e
def measure_raster(self,
r: RasterGridRequest,
@@ -146,13 +158,29 @@ class JFJochWrapper:
max_spot_count = 1000,
detect_ice_rings = True
)
self.__api.start_post(dataset_settings=dataset_settings)
try:
self.__api.start_post(dataset_settings=dataset_settings)
except Exception as e:
raise JFJochCommunicationError(
"JFJoch data collection failed to initialize for raster scan",
operation="POST",
endpoint="start_post",
base_url=self.__url,
) from e
def wait_till_done(self, timeout : int | float) -> jfjoch_client.models.ScanResult | None:
if self.__simulated:
return None
self.__api.wait_till_done_post_with_http_info(timeout=math.ceil(timeout))
return self.__api.result_scan_get()
try:
self.__api.wait_till_done_post_with_http_info(timeout=math.ceil(timeout))
return self.__api.result_scan_get()
except Exception as e:
raise JFJochCommunicationError(
"JFJoch wait/result retrieval failed",
operation="GET",
endpoint="wait_till_done_post / result_scan_get",
base_url=self.__url,
) from e
def detector(self) -> jfjoch_client.models.DetectorListElement:
l = self.__api.config_select_detector_get()