diff --git a/lerobot/common/errors.py b/lerobot/common/errors.py new file mode 100644 index 00000000..aba958a1 --- /dev/null +++ b/lerobot/common/errors.py @@ -0,0 +1,23 @@ +class ConnectionError(Exception): + """Base exception class for connection errors.""" + + pass + + +class DeviceNotConnectedError(ConnectionError): + """Exception raised when the device is not connected.""" + + def __init__(self, message="This device is not connected. Try calling `connect()` first."): + self.message = message + super().__init__(self.message) + + +class DeviceAlreadyConnectedError(ConnectionError): + """Exception raised when the device is already connected.""" + + def __init__( + self, + message="This device is already connected. Try not calling `connect()` twice.", + ): + self.message = message + super().__init__(self.message)