Merge branch 'invocation-errors' into 'v3'

Use Invocation errors for expected errors.

Closes #577

See merge request openflexure/openflexure-microscope-server!499
This commit is contained in:
Julian Stirling 2026-02-23 09:46:45 +00:00
commit e41a495ece
4 changed files with 8 additions and 6 deletions

View file

@ -19,6 +19,8 @@ from pydantic import (
model_validator, model_validator,
) )
from labthings_fastapi.exceptions import InvocationError
from openflexure_microscope_server.stitching import StitchingSettings from openflexure_microscope_server.stitching import StitchingSettings
from openflexure_microscope_server.utilities import make_name_safe, requires_lock from openflexure_microscope_server.utilities import make_name_safe, requires_lock
@ -34,7 +36,7 @@ SCAN_DATA_FILENAME = "scan_data.json"
SCAN_DATA_SCHEMA_VERSION = 2 SCAN_DATA_SCHEMA_VERSION = 2
class NotEnoughFreeSpaceError(IOError): class NotEnoughFreeSpaceError(InvocationError):
"""An exception raised if there is not enough free space on disk to scan.""" """An exception raised if there is not enough free space on disk to scan."""

View file

@ -713,11 +713,11 @@ class AutofocusThing(lt.Thing):
return "success", capture_id return "success", capture_id
class NotAPeakError(RuntimeError): class NotAPeakError(lt.exceptions.InvocationError):
"""The data to fit isn't a peak.""" """The data to fit isn't a peak."""
class NoFocusFoundError(RuntimeError): class NoFocusFoundError(lt.exceptions.InvocationError):
"""No focus found during looping Autofocus.""" """No focus found during looping Autofocus."""

View file

@ -19,11 +19,11 @@ SettingsType = TypeVar("SettingsType", bound=BaseModel)
BackgroundType = TypeVar("BackgroundType", bound=BaseModel) BackgroundType = TypeVar("BackgroundType", bound=BaseModel)
class MissingBackgroundDataError(RuntimeError): class MissingBackgroundDataError(lt.exceptions.InvocationError):
"""An error raised if checking for sample without background data set.""" """An error raised if checking for sample without background data set."""
class ChannelBlankError(RuntimeError): class ChannelBlankError(lt.exceptions.InvocationError):
"""An error raised if a channel has no measured standard deviation. """An error raised if a channel has no measured standard deviation.
This is not physical and usually means the camera has not yet booted or changed This is not physical and usually means the camera has not yet booted or changed

View file

@ -106,7 +106,7 @@ class RomDataTracker:
return {axis: int(turning_loc), other_axis: other_coord, "z": int(turning_z)} return {axis: int(turning_loc), other_axis: other_coord, "z": int(turning_z)}
class ParasiticMotionError(Exception): class ParasiticMotionError(lt.exceptions.InvocationError):
"""Custom exception raised when parasitic motion is detected. """Custom exception raised when parasitic motion is detected.
Parasitic motion is when motion in the direction not being measured Parasitic motion is when motion in the direction not being measured