CloakedReq.Error (cloaked_req v0.4.0)

Copy Markdown View Source

Represents explicit error information returned by CloakedReq.

Summary

Functions

Formats an error into a user-facing string.

Builds a structured error value.

Types

t()

@type t() :: %CloakedReq.Error{details: map(), message: String.t(), type: atom()}

Functions

format(error)

@spec format(t()) :: String.t()

Formats an error into a user-facing string.

Examples

iex> CloakedReq.Error.new(:invalid_request, "missing url") |> CloakedReq.Error.format()
"invalid_request: missing url"

new(type, message, details \\ %{})

@spec new(atom(), String.t(), map()) :: t()

Builds a structured error value.

Examples

iex> err = CloakedReq.Error.new(:invalid_request, "missing url")
iex> err.type
:invalid_request