Update error handling in update coordinator (#32452)

This commit is contained in:
Paulus Schoutsen 2020-03-04 08:05:46 -08:00 committed by GitHub
parent f62322cfb4
commit b27c46750c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 58 additions and 67 deletions

View file

@ -1,9 +1,7 @@
"""Support for the Philips Hue sensors as a platform."""
import asyncio
from datetime import timedelta
import logging
from aiohttp import client_exceptions
from aiohue import AiohueException, Unauthorized
from aiohue.sensors import TYPE_ZLL_PRESENCE
import async_timeout
@ -60,9 +58,9 @@ class SensorManager:
)
except Unauthorized:
await self.bridge.handle_unauthorized_error()
raise UpdateFailed
except (asyncio.TimeoutError, AiohueException, client_exceptions.ClientError):
raise UpdateFailed
raise UpdateFailed("Unauthorized")
except AiohueException as err:
raise UpdateFailed(f"Hue error: {err}")
async def async_register_component(self, binary, async_add_entities):
"""Register async_add_entities methods for components."""