mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Hue handle HTTP errors (#68396)
This commit is contained in:
parent
ba814af701
commit
3320606a1b
@ -6,6 +6,7 @@ from collections.abc import Callable
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
from aiohttp import client_exceptions
|
from aiohttp import client_exceptions
|
||||||
from aiohue import HueBridgeV1, HueBridgeV2, LinkButtonNotPressed, Unauthorized
|
from aiohue import HueBridgeV1, HueBridgeV2, LinkButtonNotPressed, Unauthorized
|
||||||
from aiohue.errors import AiohueException, BridgeBusy
|
from aiohue.errors import AiohueException, BridgeBusy
|
||||||
@ -14,7 +15,7 @@ import async_timeout
|
|||||||
from homeassistant import core
|
from homeassistant import core
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, Platform
|
from homeassistant.const import CONF_API_KEY, CONF_HOST, Platform
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import CONF_API_VERSION, DOMAIN
|
from .const import CONF_API_VERSION, DOMAIN
|
||||||
@ -131,7 +132,11 @@ class HueBridge:
|
|||||||
# log only
|
# log only
|
||||||
self.logger.debug("Ignored error/warning from Hue API: %s", str(err))
|
self.logger.debug("Ignored error/warning from Hue API: %s", str(err))
|
||||||
return None
|
return None
|
||||||
raise err
|
raise HomeAssistantError(f"Request failed: {err}") from err
|
||||||
|
except aiohttp.ClientError as err:
|
||||||
|
raise HomeAssistantError(
|
||||||
|
f"Request failed due connection error: {err}"
|
||||||
|
) from err
|
||||||
|
|
||||||
async def async_reset(self) -> bool:
|
async def async_reset(self) -> bool:
|
||||||
"""Reset this bridge to default state.
|
"""Reset this bridge to default state.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user