class WhatsrbCloudError(Exception):
    def __init__(self, message: str | None = None, *, status: int | None = None, body: dict | None = None):
        self.status = status
        self.body = body
        super().__init__(message or "Unknown error")


class AuthenticationError(WhatsrbCloudError):
    pass


class ForbiddenError(WhatsrbCloudError):
    pass


class NotFoundError(WhatsrbCloudError):
    pass


class ValidationError(WhatsrbCloudError):
    @property
    def details(self) -> dict:
        if self.body and isinstance(self.body, dict):
            return self.body.get("details", {})
        return {}


class ConflictError(WhatsrbCloudError):
    pass


class ServerError(WhatsrbCloudError):
    pass


class RateLimitError(WhatsrbCloudError):
    def __init__(self, message: str | None = None, *, status: int | None = None, body: dict | None = None, retry_after: int | None = None):
        self.retry_after = retry_after
        super().__init__(message, status=status, body=body)
