Dowser.Elasticsearch.Error exception (Dowser.Elasticsearch v0.4.1)

View Source

An error response returned by Elasticsearch — a non-2xx HTTP status.

:status is the HTTP status code and :body the (decoded) response body. When the body is a standard Elasticsearch 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.

Summary

Functions

Builds an error from a response status and body, extracting :type/:reason from a standard Elasticsearch error body when present.

Types

t()

@type t() :: %Dowser.Elasticsearch.Error{
  __exception__: true,
  body: term(),
  reason: String.t() | nil,
  status: non_neg_integer() | nil,
  type: String.t() | nil
}

Functions

new(status, body)

@spec new(non_neg_integer() | nil, term()) :: t()

Builds an error from a response status and body, extracting :type/:reason from a standard Elasticsearch 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.Elasticsearch.BulkError reports per item.