Skip to main content
Production document processing requires handling failures gracefully. This guide covers the error hierarchy, retry patterns, provider fallbacks, and strategies for building resilient extraction pipelines.

Error Hierarchy

The SDK provides a structured error hierarchy for precise error handling:

Error Properties

All errors extend DocloError and include:

Error Codes

Common error codes:

Basic Error Handling

Handle errors by type:

Retry with Exponential Backoff

Implement automatic retries for transient failures:
Usage:

Rate Limit Handling

Handle rate limits with proper backoff:

Provider Fallback

Use multiple providers with automatic fallback:

Circuit Breaker Pattern

Prevent cascading failures by temporarily disabling failing providers:

Partial Results Recovery

When a flow fails mid-execution, recover partial results:

Graceful Degradation

Implement degraded modes when providers fail:

Timeout Handling

Handle long-running extractions appropriately:

Observability Hooks for Error Tracking

Use hooks to track errors across your flows:

Complete Example: Resilient Pipeline

Best Practices

  1. Classify errors - Know which errors are retryable vs permanent
  2. Use exponential backoff - Prevent overwhelming failing services
  3. Add jitter - Avoid thundering herd when services recover
  4. Implement circuit breakers - Stop calling failing providers
  5. Log comprehensively - Include context for debugging
  6. Set reasonable timeouts - Balance wait time vs failure detection
  7. Plan for partial failures - Extract value from completed steps
  8. Monitor error rates - Alert on anomalies

Next Steps

Observability

Track errors and metrics

Providers

Configure fallback providers

Webhooks

Handle async failures

Multi-Provider

Increase reliability with consensus