FaroEx.Error exception (FaroEx v0.1.0)

Copy Markdown View Source

What a failed call returns. Returned, never raised — every public function gives you {:error, %FaroEx.Error{}} so failures are part of the ordinary control flow.

code is the server's own error code, passed through verbatim: validation_error, unauthorized, forbidden, not_found, conflict, credentials_not_configured, bad_request, internal_error. A transport failure (refused connection, timeout) has status: nil and code: "transport_error".

Codes are never converted to atoms: an atom per server string is a slow leak, and the set is the server's to grow.

Summary

Types

t()

@type t() :: %FaroEx.Error{
  __exception__: true,
  body: term(),
  code: String.t(),
  message: String.t(),
  status: pos_integer() | nil
}
  • :status — HTTP status, or nil for a transport failure.
  • :code — the server's error code, or "transport_error".
  • :message — human-readable, straight from the server where it gives one.
  • :body — the decoded error envelope, or nil for a transport failure.