Structured error type returned by all railsr public functions.
All public resource functions return {:ok, struct} or {:error, %Railsr.Error{}}.
Fields
:type— machine-readable error category atom:message— human-readable description:status— HTTP status code (nil for network/internal errors):code— Railsr API error code string (e.g."ERROR_ENTITY_NOT_FOUND"):request_id— value ofX-Request-Idheader from Railsr for support tracing:details— raw decoded body map for additional context:retryable?— whether the request is safe to retry
Error Types
| Type | Meaning |
|---|---|
:unauthorized | 401 — invalid/expired token |
:forbidden | 403 — insufficient OAuth scope |
:not_found | 404 — resource does not exist |
:conflict | 409 — duplicate resource |
:unprocessable | 422 — validation failure |
:rate_limited | 429 — too many requests |
:server_error | 5xx — Railsr internal error |
:circuit_open | circuit breaker tripped |
:timeout | request exceeded :timeout config |
:network | TCP-level connectivity error |
:unknown | anything else |
Summary
Functions
Build a Railsr.Error from a non-HTTP exception (timeout, network, etc.).
Build a Railsr.Error from an HTTP response body + status.
Types
@type error_type() ::
:unauthorized
| :forbidden
| :not_found
| :conflict
| :unprocessable
| :rate_limited
| :server_error
| :circuit_open
| :timeout
| :network
| :unknown
@type t() :: %Railsr.Error{ __exception__: true, code: String.t() | nil, details: map() | nil, message: String.t(), request_id: String.t() | nil, retryable?: boolean(), status: non_neg_integer() | nil, type: error_type() }
Functions
@spec from_exception(Exception.t() | atom()) :: t()
Build a Railsr.Error from a non-HTTP exception (timeout, network, etc.).
@spec from_response(non_neg_integer(), map(), map()) :: t()
Build a Railsr.Error from an HTTP response body + status.