Remove redundant exception and catch NotSuchTokenException in Overkiz integration (#103584)

This commit is contained in:
Mick Vleeshouwer 2023-11-08 12:32:37 +01:00 committed by GitHub
parent 8e99760595
commit 3697567f18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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