from __future__ import annotations

from typing import Any, Optional


class RagentOssError(Exception):
    """Base error for ragent-oss SDK operations."""

    def __init__(self, message: str, status_code: int, body: Any = None):
        super().__init__(message)
        self.status_code = status_code
        self.body = body


class AuthenticationError(RagentOssError):
    """Raised on HTTP 401 - invalid or missing API key."""

    def __init__(self, body: Any = None):
        super().__init__("Authentication failed", 401, body)


class ValidationError(RagentOssError):
    """Raised on HTTP 422 - invalid request parameters."""

    def __init__(self, body: Any = None):
        super().__init__("Validation failed", 422, body)


class UploadError(Exception):
    """Raised when PUT upload to presigned URL fails."""

    def __init__(self, message: str, status: Optional[int] = None):
        super().__init__(message)
        self.status = status


class NetworkError(Exception):
    """Raised when network connection fails."""

    def __init__(self, message: str, cause: Optional[Exception] = None):
        super().__init__(message)
        self.__cause__ = cause
