Handle kaiterra ClientConnectorError exception (#77428)

* Update api_data.py

add ClientConnectorError exception

* Update api_data.py

fix ClientConnectorError exception handling

* Update api_data.py

import in alphabetical order and better exception logging
pull/77473/head
Anil Daoud 2022-08-29 17:40:24 +09:00 committed by GitHub
parent 0c401bcab2
commit 3846efecc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@
import asyncio
from logging import getLogger
from aiohttp.client_exceptions import ClientResponseError
from aiohttp.client_exceptions import ClientConnectorError, ClientResponseError
import async_timeout
from kaiterra_async_client import AQIStandard, KaiterraAPIClient, Units
@ -55,8 +55,8 @@ class KaiterraApiData:
try:
async with async_timeout.timeout(10):
data = await self._api.get_latest_sensor_readings(self._devices)
except (ClientResponseError, asyncio.TimeoutError):
_LOGGER.debug("Couldn't fetch data from Kaiterra API")
except (ClientResponseError, ClientConnectorError, asyncio.TimeoutError) as err:
_LOGGER.debug("Couldn't fetch data from Kaiterra API: %s", err)
self.data = {}
async_dispatcher_send(self._hass, DISPATCHER_KAITERRA)
return