Skip to content
1 min read · 246 words

@nhtio/adk/batteries/llm/anthropic_messages/exceptions

Battery-scoped exception constructors for the Anthropic Messages adapter.

Remarks

Battery-scoped exception classes for the Anthropic Messages adapter. These exceptions are owned by the battery, not the ADK core, and are minted via createException from @nhtio/adk/factories. The status codes and fatal split mirror the pure HTTP Ollama battery.

Important provenance rule: ADK convention uses status 529 on fatal option and context-overflow exceptions raised by the adapter itself. Anthropic also returns a real upstream HTTP 529 overloaded_error, which is transient and retriable. An upstream 529 must be classified by provenance as E_ANTHROPIC_MESSAGES_HTTP_ERROR, with retry eligibility decided by the retry config. Never route a provider 529 into the fatal same-numbered ADK-side exceptions.

Variables

VariableDescription
E_ANTHROPIC_MESSAGES_CONTEXT_OVERFLOWThrown when the total token weight of the resolved request exceeds contextWindow.
E_ANTHROPIC_MESSAGES_HTTP_ERRORThrown when the upstream Messages endpoint returns an API error.
E_ANTHROPIC_MESSAGES_INVALID_TOOL_CALL_ARGSInstantiated for invalid model-emitted tool arguments and persisted as an error ToolCall.
E_ANTHROPIC_MESSAGES_REQUEST_TIMEOUTThrown when the request does not complete before requestTimeoutMs.
E_ANTHROPIC_MESSAGES_STREAM_ERRORThrown when a streaming Messages request emits a provider or transport failure mid-stream.
E_ANTHROPIC_MESSAGES_STREAM_STALLEDThrown when the Messages stream goes silent for longer than streamIdleTimeoutMs.
E_ANTHROPIC_MESSAGES_UNSUPPORTED_MEDIA_MODALITYRaised when an ADK media instance cannot be represented by the Anthropic Messages wire.
E_INVALID_ANTHROPIC_MESSAGES_OPTIONSThrown when resolved Anthropic Messages adapter options fail validation.