Error Handling Internals
Error Handling Internals
Section titled “Error Handling Internals”ProxAI keeps internal errors strongly typed, then projects them into compact client-facing HTTP or SSE errors. The projection boundary is centralized so provider, upstream, and translation code do not each invent their own response format.
Error projection pipeline
Section titled “Error projection pipeline”Internal error taxonomy
Section titled “Internal error taxonomy”| Error type | Meaning |
|---|---|
JsonPayloadError | Shared core JSON path/location/source details |
IngressError | Core structured request normalization or validation failure |
RequestError | Application body/path failure or wrapped IngressError |
ConfigError | Config loading and config-file reads |
InternalError | Runtime invariants, local IO, JSON serialization, internal body reads |
UpstreamError | Upstream send/status/body-read failures |
TranslationError | Core non-streaming protocol payload conversion failures |
StreamTranslationError | Core structured stream conversion and lifecycle semantics |
SseError | Application SSE carrier parsing |
ByteStreamError | Stream carrier failures |
Core domain errors are returned through Result and transparently wrapped by application errors so their source chains remain intact. Non-fatal adaptations use Observation instead; do not emit and return the same failure twice.
Do not hide semantic stream or HTTP failures inside std::io::Error; reserve IO errors for real OS/filesystem IO.
Client-facing payload
Section titled “Client-facing payload”JSON format wraps a compact error payload:
Text format returns the same compact error object as pretty-printed JSON with text/plain, which keeps raw clients readable while preserving upstream code and param details.
Preserved upstream details
Section titled “Preserved upstream details”For upstream non-2xx responses, ProxAI keeps useful details when the upstream actually provides them:
Retry-After- upstream request id headers
- rate-limit headers
- OpenAI-style
code - OpenAI-style
param - Anthropic
error.type, normalized as the provider errorcode
proxai-core::provider::normalize_provider_error owns structured JSON error normalization. The application keeps HTTP status/headers, body bytes, empty/non-JSON handling, and client-facing rendering. It should not fabricate upstream code or param values. These rules implement Behavior Contract C15 and C18.