retort v2.1.0 Retort.Response.Error

A JSON-RPC Response Error object

Summary

Functions

Uses rendered changset as data for error

Uses JSON API document as data for error. Only use when the document is a JSON API errors document

Converts JSON decoded map with String.t keys to t

Converts t to errors returned by Calcinator and Calcinator.Resources callbacks

Types

t()
t() :: %Retort.Response.Error{code: integer, data: term, message: String.t}

Functions

from_changeset(changeset)
from_changeset(Ecto.Changeset.t) :: t

Uses rendered changset as data for error.

from_document(document)
from_document(Alembic.Document.t) :: t

Uses JSON API document as data for error. Only use when the document is a JSON API errors document.

from_json(map)
from_json(%{required(binary) => integer, required(binary) => binary, optional(term) => term}) :: t

Converts JSON decoded map with String.t keys to t.

From error with data

iex> Retort.Response.Error.from_json(%{"code" => 0, "data" => "Data", "message" => "Zero"})
%Retort.Response.Error{code: 0, data: "Data", message: "Zero"}

From error without data

iex> Retort.Response.Error.from_json(%{"code" => 0, "message" => "Zero"})
%Retort.Response.Error{code: 0, data: nil, message: "Zero"}
predefined(binary)
predefined(String.t) :: t

Looks up predefined t.

to_calcinator_error(error, changeset)
to_calcinator_error(t, maybe_changeset :: Ecto.Changeset.t | nil) ::
  {:error, :bad_gateway} |
  {:error, :not_found} |
  {:error, :sandbox_access_disallowed} |
  {:error, Ecto.Changeset.t}

Converts t to errors returned by Calcinator and Calcinator.Resources callbacks.