Mediate.Error exception (mediate v0.1.0)

Copy Markdown View Source

The one exception. reason is the word that says why, and detail is the sentence a reader needs, which is also the message.

A reason an answer carries is a reason an error carries, so an error that follows a denial names what the answer named. Three reasons belong to the library and not to a decider:

  • :unsupported, for what an adapter or a configuration cannot do
  • :invalid, for a value at an edge that did not validate: a bulk write or an upsert on an audited schema, a raw call given a decision, a bad option, or a configuration that did not boot
  • :unmediated, for a call that reached the seam with no decision and no exemption

Summary

Types

Why the call failed. An error never carries :allowed.

t()

A failed call: why, and a detail that names what failed.

Functions

The error a denial makes. It names the reason the answer gave and who cannot do what. It adds the decider's own text where the answer carried one.

The error a value at an edge makes: what did not validate, and why it did not.

The reasons an error carries: a denial's reasons, and the library's own.

Types

reason()

@type reason() :: Mediate.Answer.reason() | :unsupported | :invalid | :unmediated

Why the call failed. An error never carries :allowed.

t()

@type t() :: %Mediate.Error{
  __exception__: term(),
  detail: String.t(),
  reason: reason()
}

A failed call: why, and a detail that names what failed.

Functions

denied(arg, operation, object, reason, detail \\ nil)

@spec denied(
  Mediate.subject(),
  atom(),
  Mediate.object() | atom(),
  reason(),
  String.t() | nil
) :: t()

The error a denial makes. It names the reason the answer gave and who cannot do what. It adds the decider's own text where the answer carried one.

invalid(what, detail)

@spec invalid(atom(), String.t()) :: t()

The error a value at an edge makes: what did not validate, and why it did not.

reasons()

@spec reasons() :: [reason()]

The reasons an error carries: a denial's reasons, and the library's own.