Add errors
This commit is contained in:
parent
3d3a176940
commit
3111ba78ad
|
@ -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)
|
Loading…
Reference in New Issue