Home Assistant Unofficial Reference 2024.12.1
utils.py
Go to the documentation of this file.
1 """Utility functions for Aqualink devices."""
2 
3 from __future__ import annotations
4 
5 from collections.abc import Awaitable
6 
7 import httpx
8 from iaqualink.exception import AqualinkServiceException
9 
10 from homeassistant.exceptions import HomeAssistantError
11 
12 
13 async def await_or_reraise(awaitable: Awaitable) -> None:
14  """Execute API call while catching service exceptions."""
15  try:
16  await awaitable
17  except (AqualinkServiceException, httpx.HTTPError) as svc_exception:
18  raise HomeAssistantError(f"Aqualink error: {svc_exception}") from svc_exception