From 3320606a1b25ac366364fabf50c3f935313ee993 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 21 Mar 2022 02:16:19 -0700 Subject: [PATCH] Hue handle HTTP errors (#68396) --- homeassistant/components/hue/bridge.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/hue/bridge.py b/homeassistant/components/hue/bridge.py index 346cc67d235..dd6182b244a 100644 --- a/homeassistant/components/hue/bridge.py +++ b/homeassistant/components/hue/bridge.py @@ -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.