Skip to content

Commit 4af4607

Browse files
committed
Add/rework exceptions
1 parent 7098724 commit 4af4607

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

airos/airos8.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
from .exceptions import (
1212
ConnectionAuthenticationError,
13-
ConnectionError,
1413
ConnectionSetupError,
1514
DataMissingError,
15+
DeviceConnectionError,
1616
)
1717

1818
logger = logging.getLogger(__name__)
@@ -178,13 +178,13 @@ async def login(self) -> bool:
178178
raise ConnectionAuthenticationError from None
179179
except aiohttp.ClientError as err:
180180
logger.exception("Error during login")
181-
raise ConnectionError from err
181+
raise DeviceConnectionError from err
182182

183183
async def status(self) -> dict:
184184
"""Retrieve status from the device."""
185185
if not self.connected:
186186
logger.error("Not connected, login first")
187-
raise ConnectionError from None
187+
raise DeviceConnectionError from None
188188

189189
# --- Step 2: Verify authenticated access by fetching status.cgi ---
190190
authenticated_get_headers = {**self._common_headers}
@@ -210,4 +210,4 @@ async def status(self) -> dict:
210210
logger.error(log)
211211
except aiohttp.ClientError as err:
212212
logger.exception("Error during authenticated status.cgi call")
213-
raise ConnectionError from err
213+
raise DeviceConnectionError from err

airos/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ class AirOSException(Exception):
55
"""Base error class for this AirOS library."""
66

77

8-
class ConnectionError(AirOSException):
9-
"""Raised when unable to connect."""
10-
11-
128
class ConnectionSetupError(AirOSException):
139
"""Raised when unable to prepare authentication."""
1410

@@ -19,3 +15,7 @@ class ConnectionAuthenticationError(AirOSException):
1915

2016
class DataMissingError(AirOSException):
2117
"""Raised when expected data is missing."""
18+
19+
20+
class DeviceConnectionError(AirOSException):
21+
"""Raised when unable to connect."""

0 commit comments

Comments
 (0)