Skip to main content

Error Handling

The SDK throws typed errors that you can catch and handle gracefully.

Error Types

Error Properties

All errors include: ClinikValidationError also includes:

Automatic Retries

The SDK retries automatically on:
  • 5xx server errors
  • 429 rate limit responses
  • Network failures
Retry behavior uses jittered exponential backoff to prevent thundering herd:
Configure retries:
Set retries: 0 to disable automatic retries.

PHI Sanitization

Error messages never contain Protected Health Information. Validation errors include field names and constraint descriptions, but never field values:

Best Practices

  • Always wrap SDK calls in try/catch
  • Log requestId for support tickets
  • Monitor rateLimitRemaining in meta to avoid hitting limits
  • Use retries: 0 for idempotency-sensitive operations
  • Handle ClinikValidationError separately to show field-level errors to users