1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00
ha-core/homeassistant/components/iaqualink/utils.py

18 lines
564 B
Python

"""Utility functions for Aqualink devices."""
from __future__ import annotations
from collections.abc import Awaitable
import httpx
from iaqualink.exception import AqualinkServiceException
from homeassistant.exceptions import HomeAssistantError
async def await_or_reraise(awaitable: Awaitable) -> None:
"""Execute API call while catching service exceptions."""
try:
await awaitable
except (AqualinkServiceException, httpx.HTTPError) as svc_exception:
raise HomeAssistantError(f"Aqualink error: {svc_exception}") from svc_exception