From 3697567f18e7b857d439e43c6ec1f82c00f078c6 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Wed, 8 Nov 2023 12:32:37 +0100 Subject: [PATCH] Remove redundant exception and catch NotSuchTokenException in Overkiz integration (#103584) --- homeassistant/components/overkiz/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/overkiz/__init__.py b/homeassistant/components/overkiz/__init__.py index 95fc2af8e06..d3fdda07f74 100644 --- a/homeassistant/components/overkiz/__init__.py +++ b/homeassistant/components/overkiz/__init__.py @@ -5,13 +5,14 @@ import asyncio from collections import defaultdict from dataclasses import dataclass -from aiohttp import ClientError, ServerDisconnectedError +from aiohttp import ClientError from pyoverkiz.client import OverkizClient from pyoverkiz.const import SUPPORTED_SERVERS from pyoverkiz.enums import OverkizState, UIClass, UIWidget from pyoverkiz.exceptions import ( BadCredentialsException, MaintenanceException, + NotSuchTokenException, TooManyRequestsException, ) from pyoverkiz.models import Device, Scenario @@ -67,11 +68,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: client.get_scenarios(), ] ) - except BadCredentialsException as exception: + except (BadCredentialsException, NotSuchTokenException) as exception: raise ConfigEntryAuthFailed("Invalid authentication") from exception except TooManyRequestsException as exception: raise ConfigEntryNotReady("Too many requests, try again later") from exception - except (TimeoutError, ClientError, ServerDisconnectedError) as exception: + except (TimeoutError, ClientError) as exception: raise ConfigEntryNotReady("Failed to connect") from exception except MaintenanceException as exception: raise ConfigEntryNotReady("Server is down for maintenance") from exception