diff --git a/src/aare/common/exception_handler.py b/src/aare/common/exception_handler.py index f454c357..3e7f2ab1 100644 --- a/src/aare/common/exception_handler.py +++ b/src/aare/common/exception_handler.py @@ -65,6 +65,64 @@ class MountingFailed(Exception): return self.message +class ManualMountException(Exception): + """Custom exception for manual mounting""" + def __init__(self, message: str = "Manual mounting failed"): + super().__init__(message) + self.message = message + logger.error(message, extra={"exception:": Exception}) + + def __str__(self) -> str: + return self.message + + +class SmartMagnetFaultException(Exception): + """Custom exception for smart magnet fault""" + def __init__(self, message: str = "Smart magnet fault"): + super().__init__(message) + self.message = message + logger.error(message, extra={"exception:": Exception}) + + def __str__(self) -> str: + return self.message + + +class TellMountFailedException(Exception): + """Custom exception for mount failure""" + + def __init__(self, message: str = "Tell mount failed"): + super().__init__(message) + self.message = message + logger.error(message, extra={"exception:": Exception}) + + def __str__(self) -> str: + return self.message + + +class TellCommandWhileBusyException(Exception): + """Custom exception for trying to move Tell when it is busy""" + + def __init__(self, message: str = "Tell is busy"): + super().__init__(message) + self.message = message + logger.error(message, extra={"exception:": Exception}) + + def __str__(self) -> str: + return self.message + + +class TellConnectionException(Exception): + """Custom exception for connection problems""" + + def __init__(self, message: str = "Lost connection to Tell"): + super().__init__(message) + self.message = message + logger.error(message, extra={"exception:": Exception}) + + def __str__(self) -> str: + return self.message + + class WarningTellException(Exception): def __init__(self, message: str = "Warning error in TELL"): super().__init__(message) diff --git a/src/aare/devices/tell_backend.py b/src/aare/devices/tell_backend.py index 478a6f06..14dd0187 100644 --- a/src/aare/devices/tell_backend.py +++ b/src/aare/devices/tell_backend.py @@ -33,31 +33,6 @@ POSITION_HOME = "pHome" POSITION_HEATER = "pHeatB" -class ManualMountException(Exception): - """Custom exception for manual mounting""" - pass - - -class SmartMagnetFaultException(Exception): - """Custom exception for smart magnet fault""" - pass - - -class TellMountFailedException(Exception): - """Custom exception for mount failure""" - pass - - -class TellCommandWhileBusyException(Exception): - """Custom exception for trying to move Tell when it is busy""" - pass - - -class TellConnectionException(Exception): - """Custom exception for connection problems""" - pass - - class TellBackend(Protocol): @property def url(self) -> str | None: diff --git a/src/aare/devices/tell_client.py b/src/aare/devices/tell_client.py index a9bf3f81..24290801 100755 --- a/src/aare/devices/tell_client.py +++ b/src/aare/devices/tell_client.py @@ -16,14 +16,15 @@ from aare.devices.tell_backend import ( SimTellBackend, LazyTellBackend, PShellTellBackend, - ManualMountException, POSITION_COLD, +) +from aare.common.exception_handler import ( SmartMagnetFaultException, TellConnectionException, TellMountFailedException, TellCommandWhileBusyException, + ManualMountException ) - from aare.common.logger_config import setup_logger logger = setup_logger("aareDAQ")