Hue handle HTTP errors (#68396)

pull/68254/head
Paulus Schoutsen 2022-03-21 02:16:19 -07:00 committed by GitHub
parent ba814af701
commit 3320606a1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,7 @@ from collections.abc import Callable
import logging
from typing import Any
import aiohttp
from aiohttp import client_exceptions
from aiohue import HueBridgeV1, HueBridgeV2, LinkButtonNotPressed, Unauthorized
from aiohue.errors import AiohueException, BridgeBusy
@ -14,7 +15,7 @@ import async_timeout
from homeassistant import core
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
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 .const import CONF_API_VERSION, DOMAIN
@ -131,7 +132,11 @@ class HueBridge:
# log only
self.logger.debug("Ignored error/warning from Hue API: %s", str(err))
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:
"""Reset this bridge to default state.