Improve exception catching and handling in Overkiz integration (#66604)

This commit is contained in:
Mick Vleeshouwer 2022-02-15 12:44:53 -08:00 committed by GitHub
parent c5ae43144d
commit 5568531f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View File

@ -9,8 +9,10 @@ from pyoverkiz.client import OverkizClient
from pyoverkiz.enums import EventName, ExecutionState from pyoverkiz.enums import EventName, ExecutionState
from pyoverkiz.exceptions import ( from pyoverkiz.exceptions import (
BadCredentialsException, BadCredentialsException,
InvalidEventListenerIdException,
MaintenanceException, MaintenanceException,
NotAuthenticatedException, NotAuthenticatedException,
TooManyConcurrentRequestsException,
TooManyRequestsException, TooManyRequestsException,
) )
from pyoverkiz.models import Device, Event, Place from pyoverkiz.models import Device, Event, Place
@ -67,10 +69,14 @@ class OverkizDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]):
events = await self.client.fetch_events() events = await self.client.fetch_events()
except BadCredentialsException as exception: except BadCredentialsException as exception:
raise ConfigEntryAuthFailed("Invalid authentication.") from exception raise ConfigEntryAuthFailed("Invalid authentication.") from exception
except TooManyConcurrentRequestsException as exception:
raise UpdateFailed("Too many concurrent requests.") from exception
except TooManyRequestsException as exception: except TooManyRequestsException as exception:
raise UpdateFailed("Too many requests, try again later.") from exception raise UpdateFailed("Too many requests, try again later.") from exception
except MaintenanceException as exception: except MaintenanceException as exception:
raise UpdateFailed("Server is down for maintenance.") from exception raise UpdateFailed("Server is down for maintenance.") from exception
except InvalidEventListenerIdException as exception:
raise UpdateFailed(exception) from exception
except TimeoutError as exception: except TimeoutError as exception:
raise UpdateFailed("Failed to connect.") from exception raise UpdateFailed("Failed to connect.") from exception
except (ServerDisconnectedError, NotAuthenticatedException): except (ServerDisconnectedError, NotAuthenticatedException):

View File

@ -4,7 +4,7 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/overkiz", "documentation": "https://www.home-assistant.io/integrations/overkiz",
"requirements": [ "requirements": [
"pyoverkiz==1.3.4" "pyoverkiz==1.3.5"
], ],
"zeroconf": [ "zeroconf": [
{ {

View File

@ -1749,7 +1749,7 @@ pyotgw==1.1b1
pyotp==2.6.0 pyotp==2.6.0
# homeassistant.components.overkiz # homeassistant.components.overkiz
pyoverkiz==1.3.4 pyoverkiz==1.3.5
# homeassistant.components.openweathermap # homeassistant.components.openweathermap
pyowm==3.2.0 pyowm==3.2.0

View File

@ -1118,7 +1118,7 @@ pyotgw==1.1b1
pyotp==2.6.0 pyotp==2.6.0
# homeassistant.components.overkiz # homeassistant.components.overkiz
pyoverkiz==1.3.4 pyoverkiz==1.3.5
# homeassistant.components.openweathermap # homeassistant.components.openweathermap
pyowm==3.2.0 pyowm==3.2.0