"""Typed exception hierarchy for the Memory Runtime SDK."""

from __future__ import annotations

from typing import Any


class MemoryAPIError(Exception):
    """Base error for all Memory Runtime API failures."""

    def __init__(self, *, status: int, detail: str, body: dict[str, Any] | None = None):
        self.status = status
        self.detail = detail
        self.body = body or {}
        super().__init__(f"HTTP {status}: {detail}")


class AuthorizationError(MemoryAPIError):
    """Missing or invalid API key (HTTP 401/403)."""


class PolicyDeniedError(MemoryAPIError):
    """Action denied by runtime policy (HTTP 403 with policy_denied detail)."""


class NotFoundError(MemoryAPIError):
    """Requested resource not found (HTTP 404)."""


class RateLimitError(MemoryAPIError):
    """Rate limit exceeded (HTTP 429)."""
