mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
afc256622a
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
22 lines
785 B
Python
22 lines
785 B
Python
"""Services and service helpers for fressnapf_tracker."""
|
|
|
|
from fressnapftracker import FressnapfTrackerError, FressnapfTrackerInvalidTokenError
|
|
|
|
from homeassistant.exceptions import ConfigEntryAuthFailed, HomeAssistantError
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
def handle_fressnapf_tracker_exception(exception: FressnapfTrackerError):
|
|
"""Handle the different FressnapfTracker errors."""
|
|
if isinstance(exception, FressnapfTrackerInvalidTokenError):
|
|
raise ConfigEntryAuthFailed(
|
|
translation_domain=DOMAIN,
|
|
translation_key="invalid_auth",
|
|
) from exception
|
|
raise HomeAssistantError(
|
|
translation_domain=DOMAIN,
|
|
translation_key="api_error",
|
|
translation_placeholders={"error_message": str(exception)},
|
|
) from exception
|