Error Handling

Octavus provides structured error handling across all transports. Errors are categorized by type and source, enabling you to build appropriate UI responses and monitoring.

Error Types

The onError callback receives an OctavusError with structured information:

typescript

Error Classification

Error Types

TypeDescriptionTypical Response
rate_limit_errorToo many requestsShow retry timer
quota_exceeded_errorUsage quota exceededShow upgrade prompt
authentication_errorInvalid API keyCheck configuration
permission_errorNo access to resourceCheck permissions
validation_errorInvalid requestFix request data
provider_errorLLM provider issueRetry or show error
provider_overloadedProvider at capacityRetry with backoff
provider_timeoutProvider timed outRetry
tool_errorTool execution failedShow tool error
internal_errorPlatform errorShow generic error

Error Sources

SourceDescription
platformOctavus platform error
providerLLM provider error (OpenAI, Anthropic, etc.)
toolTool execution error
clientClient-side error (network, parsing)

Type Guards

Use type guards to handle specific error types:

typescript

Provider Error Details

When errors come from LLM providers, additional details are available:

typescript

Building Error UI

tsx

Monitoring & Logging

Log errors for monitoring and debugging:

typescript

Error State

The hook exposes error state directly:

typescript

Rate Limit Handling

Rate limits include retry information:

typescript

Error Event Structure

For custom transports or direct event handling, errors follow this structure:

typescript

Tool Errors

Tool errors are handled differently—they appear inline on the tool call:

tsx

Tool errors don't trigger onError—they're captured on the tool call part itself.