Dowser. Opensearch. Error exception
(Dowser.Opensearch v0.1.0)
View Source
An error response returned by OpenSearch — a non-2xx HTTP status.
:status is the HTTP status code and :body the (decoded) response body.
When the body is a standard OpenSearch error object
(%{"error" => %{"type" => ..., "reason" => ...}}), :type and :reason are
extracted for convenience.
The body reaches this module after Dowser.Client has applied the configured
:keys option, so its keys may be strings (the default) or atoms
(keys: :atoms/:atoms!); both shapes are recognised. When the error object
carries a root_cause/caused_by entry whose reason adds something — the
case with search_phase_execution_exception, whose own reason is just
"all shards failed" — that nested reason is appended to :reason.
Some OpenSearch plugin APIs (Index State Management among them) answer with a
flat %{"error" => "..."} string rather than an error object; that shape
lands in :reason with no :type.
Summary
Functions
Builds an error from a response status and body, extracting :type/:reason
from a standard OpenSearch error body when present.
Types
@type t() :: %Dowser.Opensearch.Error{ __exception__: true, body: term(), reason: String.t() | nil, status: non_neg_integer() | nil, type: String.t() | nil }
Functions
@spec new(non_neg_integer() | nil, term()) :: t()
Builds an error from a response status and body, extracting :type/:reason
from a standard OpenSearch error body when present.
status may be nil for an error that is not a response of its own — one
bulk item's, which Dowser.Opensearch.BulkError reports per item.