Expand description
API error types and utilities translated from TypeScript errors.ts
Structs§
- Amazon
Error - Lower-level error that AWS can return
- Amazon
Output - ApiError
Message - Assistant message structure for API errors
Enums§
- ApiError
Type - API error types for classification
- SDKAssistant
Message Error - SDK assistant message error types
Constants§
- API_
ERROR_ MESSAGE_ PREFIX - Prefix for API error messages
- API_
TIMEOUT_ ERROR_ MESSAGE - API timeout error message
- CCR_
AUTH_ ERROR_ MESSAGE - CCR auth error message
- CREDIT_
BALANCE_ TOO_ LOW_ ERROR_ MESSAGE - Credit balance too low error message
- CUSTOM_
OFF_ SWITCH_ MESSAGE - Custom off switch message
- INVALID_
API_ KEY_ ERROR_ MESSAGE - Invalid API key error message
- INVALID_
API_ KEY_ ERROR_ MESSAGE_ EXTERNAL - Invalid API key error message for external sources
- NO_
RESPONSE_ REQUESTED - Constant for no response requested
- OAUTH_
ORG_ NOT_ ALLOWED_ ERROR_ MESSAGE - OAuth org not allowed error message
- ORG_
DISABLED_ ERROR_ MESSAGE_ ENV_ KEY - Organization disabled error message (env key)
- ORG_
DISABLED_ ERROR_ MESSAGE_ ENV_ KEY_ WITH_ OAUTH - Organization disabled error message (env key with OAuth)
- PROMPT_
TOO_ LONG_ ERROR_ MESSAGE - Prompt too long error message
- REPEATED_
529_ ERROR_ MESSAGE - Repeated 529 error message
- TOKEN_
REVOKED_ ERROR_ MESSAGE - Token revoked error message
Functions§
- categorize_
retryable_ api_ error - Categorize retryable API errors
- classify_
api_ error - Classifies an API error into a specific error type for analytics tracking. Returns a standardized error type string suitable for tagging.
- create_
assistant_ api_ error_ message - Create an assistant API error message
- create_
assistant_ api_ error_ message_ with_ options - Create an assistant API error message with optional parameters
- error_
to_ api_ message - Map a raw error message to a rich
ApiErrorMessagewith structured content, error type, and optional error_details. Mirrors the TypeScriptgetAssistantMessageFromError()function. - extract_
unknown_ error_ format - Given a response that doesn’t look quite right, see if it contains any known error types
- get_
error_ message_ if_ refusal - Get error message if refusal
- get_
image_ too_ large_ error_ message - Get image too large error message
- get_
oauth_ org_ not_ allowed_ error_ message - Get OAuth org not allowed error message
- get_
pdf_ invalid_ error_ message - Get PDF invalid error message
- get_
pdf_ password_ protected_ error_ message - Get PDF password protected error message
- get_
pdf_ too_ large_ error_ message - Get PDF too large error message based on session type
- get_
prompt_ too_ long_ token_ gap - Returns how many tokens over the limit a prompt-too-long error reports, or undefined if the message isn’t PTL or its error_details are unparseable.
- get_
request_ too_ large_ error_ message - Get request too large error message
- get_
token_ revoked_ error_ message - Get token revoked error message
- is_
ccr_ mode - Check if we’re in CCR (Claude Code Remote) mode. In CCR mode, auth is handled via JWTs provided by the infrastructure, not via /login. Transient auth errors should suggest retrying, not logging in. Note: This is a placeholder - actual implementation would check environment
- is_
media_ size_ error - Is this raw API error text a media-size rejection? Patterns MUST stay in sync with the getAssistantMessageFromError branches that populate error_details (~L523 PDF, ~L560 image, ~L573 many-image) and the classifyAPIError branches (~L929-946).
- is_
media_ size_ error_ message - Message-level predicate: is this assistant message a media-size rejection?
- is_
prompt_ too_ long_ message - Check if a message is a prompt too long error
- is_
valid_ api_ message - Type guard to check if a value is a valid API message response
- parse_
prompt_ too_ long_ token_ counts - Parse actual/limit token counts from a raw prompt-too-long API error message like “prompt is too long: 137500 tokens > 135000 maximum”. The raw string may be wrapped in SDK prefixes or JSON envelopes, or have different casing (Vertex), so this is intentionally lenient.
- sanitize_
html_ error - Sanitize an HTTP error body: if it looks like an HTML error page (e.g., 502/503 from a reverse proxy), extract the page title instead of dumping the full HTML into the error message.
- starts_
with_ api_ error_ prefix - Check if text starts with API error prefix