diff --git a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py index 9e3c7c9..5f7895a 100644 --- a/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py +++ b/csaxs_bec/bec_ipython_client/plugins/flomni/flomni.py @@ -2422,7 +2422,20 @@ class Flomni( # finally do the scan at this angle self._tomo_scan_at_angle(angle, subtomo_number) - @scan_repeat(max_repeats=10, default=True) + @staticmethod + def _retry_unless_flomni_error(exc: Exception, attempt: int) -> bool: + """scan_repeat() exc_handler: retry any exception except FlomniError. + + FlomniError marks a definite, non-transient failure (bad config, + unmet precondition, ...) -- e.g. _at_each_angle() raises it when a + job's at_each_angle_hook name isn't registered in this session. + Retrying that up to max_repeats times just burns 10 attempts before + surfacing a much less informative TooManyScanRestarts, instead of + the actual, actionable error message immediately. + """ + return not isinstance(exc, FlomniError) + + @scan_repeat(max_repeats=10, default=True, exc_handler=_retry_unless_flomni_error) def _tomo_scan_at_angle(self, angle, subtomo_number): if 0 <= angle < self.tomo_angle_range + 0.05: