atproto_core/xrpc
The target-agnostic XRPC vocabulary shared by every client package:
transport and XRPC error types, response checking, and JSON body
parsing. Sync and async clients (atproto_client, atproto_browser)
wrap their own send functions around these.
Types
A transport-level failure from an injected send function or from
request construction. Backends map their own error type onto these
variants; Other carries anything without a dedicated shape (including
DPoP signing failures surfaced through a wrapped client’s send).
pub type TransportError {
InvalidUrl(url: String)
Timeout
ConnectionFailed(detail: String)
Other(detail: String)
}
Constructors
-
InvalidUrl(url: String) -
Timeout -
ConnectionFailed(detail: String) -
Other(detail: String)
pub type XrpcError {
RequestFailed(TransportError)
BadStatus(
status: Int,
error: option.Option(String),
message: option.Option(String),
body: String,
)
DecodeFailed(String)
}
Constructors
-
RequestFailed(TransportError) -
BadStatus( status: Int, error: option.Option(String), message: option.Option(String), body: String, )A non-2xx response. atproto error bodies are JSON
{error, message}; both are parsed out (when present) so callers can branch onerror(e.g.ExpiredToken) instead of string-matching the raw body. -
DecodeFailed(String)
Values
pub fn check_ok(
resp: response.Response(String),
) -> Result(response.Response(String), XrpcError)
Turn a received response into a Result: Ok on 2xx, else a BadStatus
with the atproto error/message parsed out of the body when present.
pub fn check_ok_bits(
resp: response.Response(BitArray),
) -> Result(response.Response(BitArray), XrpcError)
check_ok for byte-bodied responses (blob and image downloads); the
error body on a bad status is decoded leniently for the message.
pub fn describe(error: XrpcError) -> String
A one-line human-readable rendering of an error, for CLI and log output.
pub fn parse(
body: String,
decoder: decode.Decoder(a),
) -> Result(a, XrpcError)
Decode a JSON response body, wrapping decode failures as DecodeFailed.
pub fn transport_error_to_string(error: TransportError) -> String
A one-line human-readable rendering of a transport error.