# `Cardbox.Error`
[🔗](https://github.com/hattoriai/cardbox/blob/v0.1.0/lib/cardbox/error.ex#L1)

Why a write or a query did not happen.

`reason` is one of:

  * `:invalid` - a value, a field or a query that does not check; `errors`
    says which, as `{field_key, message}` (`nil` for the whole of it);
  * `:conflict` - a value someone changed meanwhile (the `:expect` option
    of an update); `current` is the record as it is now;
  * `:not_found` - a record, field or view that is not in the collection;
  * `:unauthorized` - the module's `c:Cardbox.allow?/3` said no.

`message` says it in words, for a person or an agent.

# `t`

```elixir
@type t() :: %Cardbox.Error{
  __exception__: term(),
  current: term(),
  errors: [{String.t() | nil, String.t()}],
  message: String.t(),
  reason: :invalid | :conflict | :not_found | :unauthorized
}
```

---

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