# `Mediate.Error`
[🔗](https://github.com/mrmeku/mediate/blob/v0.1.0/lib/mediate/error.ex#L1)

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

# `reason`

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

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

# `t`

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

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

# `denied`

```elixir
@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`

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

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

# `reasons`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
