Wardrik.Error exception (wardrik_protocol v0.1.0-rc.1)

Copy Markdown

An operation's failure, as the protocol's error.

%Wardrik.Error{type: :not_found, message: "No agent acme/triage."}

type is one of type/0. message is for people to read.

Summary

Functions

Returns error as the protocol's JSON error body.

Returns an error of type with message.

Types

t()

@type t() :: %Wardrik.Error{__exception__: term(), message: String.t(), type: type()}

type()

@type type() ::
  :invalid_request
  | :unauthorized
  | :forbidden
  | :not_found
  | :conflict
  | :not_supported
  | :unavailable
  | :internal

Functions

json(error)

@spec json(t()) :: map()

Returns error as the protocol's JSON error body.

Wardrik.Error.json(Wardrik.Error.new(:not_found, "No agent acme/triage."))
#=> %{"error" => %{"type" => "not_found", "message" => "No agent acme/triage."}}

new(type, message)

@spec new(type(), String.t()) :: t()

Returns an error of type with message.