Atex.XRPC.Error (atex v0.9.1)

View Source

Represents an XRPC error response.

When a lexicon defines errors for a query or procedure, the XRPC client will attempt to coerce error responses into typed error structs. If the error matches a known lexicon error, error_struct will contain the specific struct. If the error is unknown, error_struct will be nil.

XRPC Error Response Format

Per the XRPC spec, error responses have the following JSON structure:

{
  "error": "ErrorName",
  "message": "Human-readable description"
}

Examples

%Atex.XRPC.Error{error: "SomethingBroke", message: "Database connection failed"}

# With a typed error struct
%Atex.XRPC.Error{
  error: "SomethingBroke",
  message: "Database connection failed",
  error_struct: %Com.Example.DoThing.Errors.SomethingBroke{message: "Database connection failed"}
}

Summary

Types

t()

@type t() :: %Atex.XRPC.Error{
  error: String.t(),
  error_struct: module() | nil,
  message: String.t() | nil
}