A normalized API error.
Both transports collapse into this one shape. A REST call that returns a 4xx or
5xx becomes a GhEx.Error carrying the status and GitHub's error body. A GraphQL
call that returns a 200-with-errors body normalizes into the same struct via
from_graphql/2.
It is also an exception, so streaming helpers that cannot return an :error
tuple can raise it.
Summary
Functions
Builds an error from a GraphQL 200-with-errors response.
Builds an error from a failed REST response.
Types
@type t() :: %GhEx.Error{ __exception__: true, body: term(), documentation_url: String.t() | nil, errors: list() | nil, message: String.t() | nil, status: pos_integer() | nil }
Functions
Builds an error from a GraphQL 200-with-errors response.
GraphQL returns HTTP 200 even on failure, with the failures in an errors
array and any partial result in data. Both are preserved: :errors holds the
array, :message is the first error's message, and :body carries the whole
%{"data" => ..., "errors" => ...} envelope so partial data stays reachable.
@spec from_response(Req.Response.t()) :: t()
Builds an error from a failed REST response.
Populates :status, :message, :body, :errors, and :documentation_url
from the response status and JSON body. :errors is set when the body carries
a top-level "errors" array.