Zep.Error exception (Zep v1.0.0)

Copy Markdown View Source

A structured representation of a failed Zep API call.

Every {:error, reason} returned by a Zep.* resource function is either a %Zep.Error{} (the API responded, but with a non-2xx status) or a %Zep.TransportError{} (the request never got a response at all - DNS, connect timeout, TLS, etc).

%Zep.Error{} implements the Exception behaviour so it can also be raised directly, and integrates with errors.Is-style matching via plain pattern matching on :reason:

case Zep.Thread.get_summary(client, "thread-1") do
  {:ok, summary} -> summary
  {:error, %Zep.Error{reason: :not_found}} -> nil
  {:error, %Zep.Error{reason: :forbidden}} -> {:error, :plan_upgrade_required}
  {:error, error} -> raise error
end

Summary

Functions

Whether this error is generally safe to retry (429 and 5xx).

Types

reason()

@type reason() ::
  :bad_request
  | :unauthorized
  | :forbidden
  | :not_found
  | :conflict
  | :unprocessable_entity
  | :rate_limited
  | :internal_server_error
  | :service_unavailable
  | :unknown

t()

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

Functions

retriable?(error)

@spec retriable?(t()) :: boolean()

Whether this error is generally safe to retry (429 and 5xx).