|
9 | 9 | from urllib.parse import urlparse |
10 | 10 |
|
11 | 11 | import aiohttp |
| 12 | +from aiohttp.client_exceptions import ClientConnectorError |
12 | 13 | from mashumaro.exceptions import InvalidFieldValue, MissingField |
13 | 14 |
|
14 | 15 | from .data import AirOS8Data as AirOSData, redact_data_smart |
@@ -186,12 +187,16 @@ async def login(self) -> bool: |
186 | 187 | log = f"Login failed with status {response.status}. Full Response: {response.text}" |
187 | 188 | _LOGGER.error(log) |
188 | 189 | raise AirOSConnectionAuthenticationError from None |
189 | | - except (TimeoutError, aiohttp.ClientError) as err: |
190 | | - _LOGGER.exception("Error during login") |
191 | | - raise AirOSDeviceConnectionError from err |
| 190 | + |
192 | 191 | except asyncio.CancelledError: |
193 | 192 | _LOGGER.info("Login task was cancelled") |
194 | 193 | raise |
| 194 | + except (TimeoutError, ClientConnectorError) as err: |
| 195 | + _LOGGER.exception("Error during login") |
| 196 | + raise AirOSDeviceConnectionError from err |
| 197 | + except aiohttp.ClientError as err: |
| 198 | + _LOGGER.exception("Unexpected client error during login") |
| 199 | + raise AirOSDeviceConnectionError from err |
195 | 200 |
|
196 | 201 | def derived_data( |
197 | 202 | self, response: dict[str, Any] | None = None |
@@ -302,12 +307,15 @@ async def status(self) -> AirOSData: |
302 | 307 | response_text, |
303 | 308 | ) |
304 | 309 | raise AirOSDeviceConnectionError |
305 | | - except (TimeoutError, aiohttp.ClientError) as err: |
306 | | - _LOGGER.exception("Status API call failed: %s", err) |
307 | | - raise AirOSDeviceConnectionError from err |
308 | 310 | except asyncio.CancelledError: |
309 | 311 | _LOGGER.info("API status retrieval task was cancelled") |
310 | 312 | raise |
| 313 | + except (TimeoutError, ClientConnectorError) as err: |
| 314 | + _LOGGER.exception("Status API call failed: %s", err) |
| 315 | + raise AirOSDeviceConnectionError from err |
| 316 | + except aiohttp.ClientError as err: |
| 317 | + _LOGGER.exception("Unexpected client error during status API call") |
| 318 | + raise AirOSDeviceConnectionError from err |
311 | 319 |
|
312 | 320 | async def stakick(self, mac_address: str = None) -> bool: |
313 | 321 | """Reconnect client station.""" |
@@ -340,12 +348,16 @@ async def stakick(self, mac_address: str = None) -> bool: |
340 | 348 | log = f"Unable to restart connection response status {response.status} with {response_text}" |
341 | 349 | _LOGGER.error(log) |
342 | 350 | return False |
343 | | - except (TimeoutError, aiohttp.ClientError) as err: |
344 | | - _LOGGER.exception("Error during call to reconnect remote: %s", err) |
345 | | - raise AirOSDeviceConnectionError from err |
| 351 | + |
346 | 352 | except asyncio.CancelledError: |
347 | 353 | _LOGGER.info("Reconnect task was cancelled") |
348 | 354 | raise |
| 355 | + except (TimeoutError, ClientConnectorError) as err: |
| 356 | + _LOGGER.exception("Error during call to reconnect remote: %s", err) |
| 357 | + raise AirOSDeviceConnectionError from err |
| 358 | + except aiohttp.ClientError as err: |
| 359 | + _LOGGER.exception("Unexpected client error reconnect request") |
| 360 | + raise AirOSDeviceConnectionError from err |
349 | 361 |
|
350 | 362 | async def provmode(self, active: bool = False) -> bool: |
351 | 363 | """Set provisioning mode.""" |
@@ -379,9 +391,13 @@ async def provmode(self, active: bool = False) -> bool: |
379 | 391 | log = f"Unable to change provisioning mode response status {response.status} with {response_text}" |
380 | 392 | _LOGGER.error(log) |
381 | 393 | return False |
382 | | - except (TimeoutError, aiohttp.ClientError) as err: |
383 | | - _LOGGER.exception("Error during call to change provisioning mode: %s", err) |
384 | | - raise AirOSDeviceConnectionError from err |
| 394 | + |
385 | 395 | except asyncio.CancelledError: |
386 | 396 | _LOGGER.info("Provisioning mode change task was cancelled") |
387 | 397 | raise |
| 398 | + except (TimeoutError, ClientConnectorError) as err: |
| 399 | + _LOGGER.exception("Error during call to change provisioning mode: %s", err) |
| 400 | + raise AirOSDeviceConnectionError from err |
| 401 | + except aiohttp.ClientError as err: |
| 402 | + _LOGGER.exception("Unexpected client error changing provisioning mode") |
| 403 | + raise AirOSDeviceConnectionError from err |
0 commit comments