Spaces:
Running
Running
File size: 1,287 Bytes
261c237 e99df76 261c237 2415446 a9e27c0 2415446 a9e27c0 2415446 261c237 2415446 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | from __future__ import annotations
"""Deterministic application and readiness errors."""
from collections.abc import Iterable
from free_claude_code.core.failures import FailureKind
class ApplicationError(Exception):
"""Base for request/readiness failures, not finalized upstream failures."""
kind: FailureKind
status_code: int
def __init__(self, message: str, *, error_code: str | None = None) -> None:
super().__init__(message)
self.message = message
self.error_code = error_code
class InvalidRequestError(ApplicationError):
"""The accepted request cannot be executed deterministically."""
kind = FailureKind.INVALID_REQUEST
status_code = 400
class UnknownProviderError(InvalidRequestError):
"""The configured provider identifier is not registered."""
@classmethod
def for_provider(
cls, provider_id: str, supported_provider_ids: Iterable[str]
) -> UnknownProviderError:
supported = "', '".join(supported_provider_ids)
return cls(f"Unknown provider_type: '{provider_id}'. Supported: '{supported}'")
class ApplicationUnavailableError(ApplicationError):
"""The application cannot currently provide a request runtime."""
kind = FailureKind.UNAVAILABLE
status_code = 503
|