|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +import asyncio |
5 | 6 | import json |
6 | 7 | import logging |
7 | 8 | from typing import Any |
@@ -185,13 +186,12 @@ async def login(self) -> bool: |
185 | 186 | log = f"Login failed with status {response.status}. Full Response: {response.text}" |
186 | 187 | _LOGGER.error(log) |
187 | 188 | raise AirOSConnectionAuthenticationError from None |
188 | | - except ( |
189 | | - aiohttp.ClientError, |
190 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
191 | | - aiohttp.client_exceptions.ClientConnectorError, |
192 | | - ) as err: |
| 189 | + except (TimeoutError, aiohttp.ClientError) as err: |
193 | 190 | _LOGGER.exception("Error during login") |
194 | 191 | raise AirOSDeviceConnectionError from err |
| 192 | + except asyncio.CancelledError: |
| 193 | + _LOGGER.info("Login task was cancelled") |
| 194 | + raise |
195 | 195 |
|
196 | 196 | def derived_data( |
197 | 197 | self, response: dict[str, Any] | None = None |
@@ -302,13 +302,12 @@ async def status(self) -> AirOSData: |
302 | 302 | response_text, |
303 | 303 | ) |
304 | 304 | raise AirOSDeviceConnectionError |
305 | | - except ( |
306 | | - aiohttp.ClientError, |
307 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
308 | | - aiohttp.client_exceptions.ClientConnectorError, |
309 | | - ) as err: |
310 | | - _LOGGER.error("Status API call failed: %s", err) |
| 305 | + except (TimeoutError, aiohttp.ClientError) as err: |
| 306 | + _LOGGER.exception("Status API call failed: %s", err) |
311 | 307 | raise AirOSDeviceConnectionError from err |
| 308 | + except asyncio.CancelledError: |
| 309 | + _LOGGER.info("API status retrieval task was cancelled") |
| 310 | + raise |
312 | 311 |
|
313 | 312 | async def stakick(self, mac_address: str = None) -> bool: |
314 | 313 | """Reconnect client station.""" |
@@ -341,13 +340,12 @@ async def stakick(self, mac_address: str = None) -> bool: |
341 | 340 | log = f"Unable to restart connection response status {response.status} with {response_text}" |
342 | 341 | _LOGGER.error(log) |
343 | 342 | return False |
344 | | - except ( |
345 | | - aiohttp.ClientError, |
346 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
347 | | - aiohttp.client_exceptions.ClientConnectorError, |
348 | | - ) as err: |
349 | | - _LOGGER.exception("Error during reconnect request call") |
| 343 | + except (TimeoutError, aiohttp.ClientError) as err: |
| 344 | + _LOGGER.exception("Error during call to reconnect remote: %s", err) |
350 | 345 | raise AirOSDeviceConnectionError from err |
| 346 | + except asyncio.CancelledError: |
| 347 | + _LOGGER.info("Reconnect task was cancelled") |
| 348 | + raise |
351 | 349 |
|
352 | 350 | async def provmode(self, active: bool = False) -> bool: |
353 | 351 | """Set provisioning mode.""" |
@@ -381,10 +379,9 @@ async def provmode(self, active: bool = False) -> bool: |
381 | 379 | log = f"Unable to change provisioning mode response status {response.status} with {response_text}" |
382 | 380 | _LOGGER.error(log) |
383 | 381 | return False |
384 | | - except ( |
385 | | - aiohttp.ClientError, |
386 | | - aiohttp.client_exceptions.ConnectionTimeoutError, |
387 | | - aiohttp.client_exceptions.ClientConnectorError, |
388 | | - ) as err: |
389 | | - _LOGGER.exception("Error during provisioning mode call") |
| 382 | + except (TimeoutError, aiohttp.ClientError) as err: |
| 383 | + _LOGGER.exception("Error during call to change provisioning mode: %s", err) |
390 | 384 | raise AirOSDeviceConnectionError from err |
| 385 | + except asyncio.CancelledError: |
| 386 | + _LOGGER.info("Provisioning mode change task was cancelled") |
| 387 | + raise |
0 commit comments