28 lines
769 B
Python
28 lines
769 B
Python
from __future__ import annotations
|
|
|
|
|
|
class HaClientError(Exception):
|
|
"""Base class for Home Assistant integration failures."""
|
|
|
|
public_detail = "Home Assistant is currently unavailable."
|
|
|
|
|
|
class HaTimeoutError(HaClientError):
|
|
public_detail = "Home Assistant request timed out."
|
|
|
|
|
|
class HaHttpError(HaClientError):
|
|
public_detail = "Home Assistant returned an error."
|
|
|
|
def __init__(self, status_code: int, message: str | None = None) -> None:
|
|
super().__init__(message or self.public_detail)
|
|
self.status_code = status_code
|
|
|
|
|
|
class HaAuthError(HaHttpError):
|
|
public_detail = "Home Assistant authentication failed."
|
|
|
|
|
|
class HaUnexpectedPayloadError(HaClientError):
|
|
public_detail = "Home Assistant returned an unexpected response."
|