From 3111ba78ada9f5fff9768726b4ed8207287cb1e8 Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Mon, 3 Mar 2025 18:44:15 +0100 Subject: [PATCH] Add errors --- lerobot/common/errors.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lerobot/common/errors.py 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)