DocRaptor.Error (DocRaptor v0.1.2)

Copy Markdown View Source

Structured error from client validation or the DocRaptor API.

All public APIs return {:error, %DocRaptor.Error{}} on failure (no bang functions). This is not an exception: there is no defexception, so do not raise it and do not call Exception.message/1 on it — pattern-match the struct (see Usage).

ReasonWhen
:missing_api_keyClient.new/1 without a non-empty :api_key
:invalid_documentLocal encode failed (name / type / content xor url)
:apiNon-2xx HTTP or unexpected DocRaptor JSON
:transportReq/network failure before a usable HTTP response
:timeoutDocRaptor.await_async_doc/3 exceeded :timeout_ms
:async_failedAsync status reported failed

Fields:

  • :reason — tagged atom above
  • :message — human-readable summary (for :api, often extracted from XML <error> tags)
  • :status — HTTP status when available
  • :body — raw response body (often binary), transport reason, or %Status{}

Summary

Types

reason()

@type reason() ::
  :missing_api_key
  | :invalid_document
  | :api
  | :transport
  | :timeout
  | :async_failed
  | atom()

t()

@type t() :: %DocRaptor.Error{
  body: term(),
  message: String.t(),
  reason: reason(),
  status: pos_integer() | nil
}