tesla v0.10.0 Tesla.Middleware.Tuples View Source

Return :ok / :error tuples for successful HTTP transations, i.e. when the request is completed (no network errors etc) - but it can still be an application-level error (i.e. 404 or 500).

NOTE: This middleware must be included as the first in the stack (before other middleware)

Example usage

defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.Tuples
  plug Tesla.Middleware.JSON
end

Options

  • :rescue_errors - list exceptions to be rescued, defaults to :all (See below)

The default behaviour is to rescue Tesla.Error exceptions but let other pass through. It can be customized by passing a rescue_error: option:

Rescue other exceptions

plug Tesla.Middleware.Tuples, rescue_errors: [MyCustomError]

Rescue all exceptions

plug Tesla.Middleware.Tuples, rescue_errors: :all

Link to this section Summary

Link to this section Functions

Callback implementation for Tesla.Middleware.call/3.