mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Fix iaqualink exception handling after switch to httpx (#87898)
Fix exception handling after switch to httpx
This commit is contained in:
parent
32a6280139
commit
6680e819e5
@ -7,7 +7,7 @@ from functools import wraps
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any, Concatenate, ParamSpec, TypeVar
|
from typing import Any, Concatenate, ParamSpec, TypeVar
|
||||||
|
|
||||||
import aiohttp.client_exceptions
|
import httpx
|
||||||
from iaqualink.client import AqualinkClient
|
from iaqualink.client import AqualinkClient
|
||||||
from iaqualink.device import (
|
from iaqualink.device import (
|
||||||
AqualinkBinarySensor,
|
AqualinkBinarySensor,
|
||||||
@ -77,10 +77,7 @@ async def async_setup_entry( # noqa: C901
|
|||||||
_LOGGER.error("Failed to login: %s", login_exception)
|
_LOGGER.error("Failed to login: %s", login_exception)
|
||||||
await aqualink.close()
|
await aqualink.close()
|
||||||
return False
|
return False
|
||||||
except (
|
except (asyncio.TimeoutError, httpx.HTTPError) as aio_exception:
|
||||||
asyncio.TimeoutError,
|
|
||||||
aiohttp.client_exceptions.ClientConnectorError,
|
|
||||||
) as aio_exception:
|
|
||||||
await aqualink.close()
|
await aqualink.close()
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
f"Error while attempting login: {aio_exception}"
|
f"Error while attempting login: {aio_exception}"
|
||||||
@ -149,7 +146,7 @@ async def async_setup_entry( # noqa: C901
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
await system.update()
|
await system.update()
|
||||||
except AqualinkServiceException as svc_exception:
|
except (AqualinkServiceException, httpx.HTTPError) as svc_exception:
|
||||||
if prev is not None:
|
if prev is not None:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Failed to refresh system %s state: %s",
|
"Failed to refresh system %s state: %s",
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import httpx
|
||||||
from iaqualink.client import AqualinkClient
|
from iaqualink.client import AqualinkClient
|
||||||
from iaqualink.exception import (
|
from iaqualink.exception import (
|
||||||
AqualinkServiceException,
|
AqualinkServiceException,
|
||||||
@ -42,7 +43,7 @@ class AqualinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
pass
|
pass
|
||||||
except AqualinkServiceUnauthorizedException:
|
except AqualinkServiceUnauthorizedException:
|
||||||
errors["base"] = "invalid_auth"
|
errors["base"] = "invalid_auth"
|
||||||
except AqualinkServiceException:
|
except (AqualinkServiceException, httpx.HTTPError):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
else:
|
else:
|
||||||
return self.async_create_entry(title=username, data=user_input)
|
return self.async_create_entry(title=username, data=user_input)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user