from typing import Any from fastapi import HTTPException, status class FeishuAPIError(HTTPException): """Normalized outbound Feishu failure with retry classification.""" def __init__( self, detail: str, *, retryable: bool, http_status: int | None = None, provider_code: int | str | None = None, provider_response: dict[str, Any] | None = None, ) -> None: super().__init__( status_code=( status.HTTP_503_SERVICE_UNAVAILABLE if retryable else status.HTTP_502_BAD_GATEWAY ), detail=detail, ) self.retryable = retryable self.http_status = http_status self.provider_code = provider_code self.provider_response = provider_response or {}