from __future__ import annotations

from dataclasses import dataclass
from typing import Any


class Pd4castrApiError(Exception):
    pass


class AuthenticationError(Pd4castrApiError):
    pass


class NotFoundError(Pd4castrApiError):
    pass


# exceptions must be mutable so python can attach traceback/cause details
@dataclass
class ApiError(Pd4castrApiError):
    status_code: int
    message: str
    body: Any | None = None

    def __str__(self) -> str:  # pragma: no cover
        return f"{self.status_code}: {self.message}"
