Structured error types returned by all Codat API functions.
All API functions return {:ok, result} or {:error, %Codat.Error{}}.
Error Types
| Type | HTTP Status | Description |
|---|---|---|
:unauthorized | 401 | Invalid or missing API key |
:payment_required | 402 | Free tier limit exceeded |
:forbidden | 403 | Insufficient permissions |
:not_found | 404 | Resource or data type not found |
:conflict | 409 | Data not yet ready or resource conflict |
:rate_limited | 429 | Too many requests |
:bad_request | 400 | Invalid request body or parameters |
:server_error | 5xx | Codat internal server error |
:service_unavailable | 503 | Service temporarily unavailable |
:network_error | N/A | TCP/TLS/connection failure |
:timeout | N/A | Request timed out |
:json_decode_error | N/A | Unexpected response body |
Summary
Functions
Builds a %Codat.Error{} from a network/transport-level error.
Builds a %Codat.Error{} from an HTTP response map.
Human-readable string representation of the error.
Returns true if the error is considered retryable (transient).
Types
@type error_type() ::
:unauthorized
| :payment_required
| :forbidden
| :not_found
| :conflict
| :rate_limited
| :bad_request
| :unprocessable
| :server_error
| :service_unavailable
| :network_error
| :timeout
| :json_decode_error
| :unknown
@type t() :: %Codat.Error{ correlation_id: String.t() | nil, detail: map() | nil, message: String.t() | nil, raw_body: String.t() | nil, retry_after: non_neg_integer() | nil, status_code: non_neg_integer() | nil, type: error_type() }
Functions
@spec from_exception(Exception.t()) :: t()
Builds a %Codat.Error{} from a network/transport-level error.
Builds a %Codat.Error{} from an HTTP response map.
Human-readable string representation of the error.
Returns true if the error is considered retryable (transient).