# `Trellis.Error`
[🔗](https://github.com/salesforce-misc/trellis/blob/v0.1.0-alpha/clients/elixir/lib/trellis/error.ex#L1)

An error from Trellis: a stable `code` and the engine's message, and
nothing else (ADR-0010 decision 4).

Non-bang functions return `{:error, %Trellis.Error{}}`; bang functions
raise it.

`code` is one of `t:code/0`. The engine's error codes are an open set, so a
code this version of the binding doesn't know arrives as `:unknown`, with
the engine's code named in the message, rather than crashing.

# `code`

```elixir
@type code() ::
  :parse
  | :validation
  | :connectivity
  | :conflict
  | :not_found
  | :timeout
  | :internal
  | :unknown
```

- `:parse`: the statement text isn't valid grammar.
- `:validation`: well-formed but rejected (a bad option, an unknown column,
  a type mismatch, a call on a handle that has been shut down).
- `:connectivity`: the database couldn't be reached, or the connection
  dropped.
- `:conflict`: clashes with something that already exists.
- `:not_found`: names something that doesn't exist.
- `:timeout`: a bounded wait ran out before its condition held (for
  example, the target hadn't caught up within the timeout you gave, or
  `Trellis.release_key/4` waited out the lock timeout for the pages in
  flight on its table), or a call ran out of its 30-second deadline (the
  server stopped what the call started and rolled it back). Expected, not
  a bug: retry, or allow longer.
- `:internal`: a Trellis bug or an unexpected database failure.
- `:unknown`: a code newer than this binding.

# `t`

```elixir
@type t() :: %Trellis.Error{__exception__: true, code: code(), message: String.t()}
```

---

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