DetoxifySh.Error exception (DetoxifySh v0.1.0)

Copy Markdown

An error from the API that no more specific exception describes, including codes newer than this client. Every exception the client returns has the same fields:

  • :code - the API's stable error code, a string (so a code newer than this client still arrives); "unexpected_response" when the answer was not the API's; nil for a network problem.
  • :status - the HTTP status, or nil if no response arrived.
  • :message - for people, and it may change: match on the module or :code, not on it.
  • :details - per-field problems on invalid_request, as a list of %{path: String.t(), message: String.t()}; otherwise nil.
  • :help_url - where a person can resolve it (subscribe, pay or sign up), on quota and suspension.
  • :retry_after - seconds the API asked us to wait before trying again, if it said.

The exceptions are DetoxifySh.InvalidRequestError, DetoxifySh.AuthenticationError, DetoxifySh.QuotaExceededError, DetoxifySh.AccountSuspendedError, DetoxifySh.RateLimitError, DetoxifySh.ServiceUnavailableError, DetoxifySh.NetworkError and this one. None holds the API key, so none can print it.

Summary

Types

detail()

@type detail() :: %{path: String.t(), message: String.t()}

t()

@type t() :: %{
  __struct__: module(),
  __exception__: true,
  code: String.t() | nil,
  status: pos_integer() | nil,
  message: String.t(),
  details: [detail()] | nil,
  help_url: String.t() | nil,
  retry_after: non_neg_integer() | nil
}