Attio.Error exception (Attio v0.3.0)

Copy Markdown View Source

Represents an error response from the Attio API.

All four fields are populated from the JSON error body returned by the API:

%Attio.Error{
  status: 404,
  type: "invalid_request_error",
  code: "not_found",
  message: "Object 'foobar' not found."
}

When the body is missing some of these fields, :type/:code fall back to "unknown_error"/"unknown" and :message to an inspected copy of the body.

Attio.Error is itself an exception, so it can be raised directly and works with Exception.message/1:

{:error, %Attio.Error{} = error} = Attio.Objects.get(client, "missing")
raise error
# ** (Attio.Error) Attio API error (HTTP 404, invalid_request_error/not_found): ...

Transport errors (connection failures, timeouts) are returned as the underlying exception (e.g. Req.TransportError) rather than Attio.Error.

Summary

Types

t()

@type t() :: %Attio.Error{
  __exception__: true,
  code: String.t(),
  message: String.t(),
  status: non_neg_integer(),
  type: String.t()
}