"""Canonical error codes and HTTP status code mapping."""

from __future__ import annotations

from enum import StrEnum

from pydantic import BaseModel


class ErrorCode(StrEnum):
    """Canonical error codes for Langfuse integrations."""

    TIMEOUT = "timeout"
    UNAVAILABLE = "unavailable"
    AUTH = "auth"
    MALFORMED_REQUEST = "malformed_request"
    INTERNAL_ERROR = "internal_error"


class StatusCodeMapping(BaseModel):
    """Maps HTTP status codes to error categories for Langfuse responses."""

    timeout: set[int] = {408}
    auth: set[int] = {401, 403}
    malformed_request: set[int] = {400, 404, 409, 410, 422}
    unavailable: set[int] = {425, 429, 500, 502, 503, 504}
