Skip to main content
The SDK uses typed exceptions to communicate errors. All exceptions inherit from ArmorError.

Exception Hierarchy

Exception hierarchy showing ArmorError as base with specific error types

Import Exceptions


Exception Types

ArmorError

Base exception for all SDK errors.
Example:

AuthenticationError

Raised when authentication fails (401).
Common causes:
  • Invalid API key
  • Expired or revoked key
  • Missing Authorization header

AuthorizationError

Raised when authorization fails (403). The API key is valid but lacks permissions.
Example:
Common causes:
  • Using read-only key for write operations
  • Using read-write key for admin operations

NotFoundError

Raised when a resource doesn’t exist (404).
Example:

ValidationError

Raised when request parameters are invalid (422).
Example:

RateLimitError

Raised when rate limit is exceeded (429).
Example:

ServerError

Raised for server-side errors (5xx).
Example:

StalenessError

Raised by require_fresh() when data is stale. This is a data quality exception, not an API error.
Example:

Best Practices

Catch Specific Exceptions

Retry with Backoff

Pipeline Gate Pattern


Debugging

Enable Request Logging

Inspect Error Details

Check API Key Validity

Common Questions

Which exception should I catch to fail a pipeline on stale data?

Catch StalenessError, which is raised by client.freshness.require_fresh(asset) when the asset is past its freshness threshold. It carries asset, hours_since_update, and threshold_hours so you can log actionable context. Let it propagate in Airflow tasks to mark the task failed cleanly.

How do I distinguish a transient server error from a permanent one?

Catch ServerError (5xx) separately from ArmorError and retry with backoff; these are usually transient. ValidationError and NotFoundError are permanent for the given input, so retrying won’t help. The “Retry with Backoff” example above shows the pattern for 429 + 5xx specifically.

What’s the difference between AuthenticationError and AuthorizationError?

AuthenticationError (401) means the API key itself is missing, invalid, or revoked. AuthorizationError (403) means the key is valid but lacks the scope the endpoint requires. The latter exposes required_scope and current_scope attributes so you can point users at the right key to use.

How do I debug an unexpected error from the SDK?

Enable httpx debug logging (logging.getLogger("httpx").setLevel(logging.DEBUG)) to see the raw request and response, then inspect e.message, e.code, and e.details on the caught ArmorError. For ValidationError, e.field_errors points at the exact fields the API rejected.