# `Macaw.Format.Error`
[🔗](https://github.com/dcoai/macaw_format/blob/v0.1.0/lib/macaw/format/error.ex#L1)

What every `!` twin raises (spec/00 §3): its value twin's `{:error, reason}`, with the
reason's term kept and its words for the message.

`reason` is the term exactly as the twin answers it, a list of `{path, reason}` faults or
one bare reason, so a caller that catches nothing still reads the terms in a crash
report, and a test asserts them without parsing words:

    iex> error = Macaw.Format.Error.exception(reason: [{[], {:width, 1024}}], what: "not a format")
    iex> {error.reason, Exception.message(error)}
    {[{[], {:width, 1024}}], "not a format: value: is wider than 1024 characters, the most a format writes"}

`exception/1` takes `reason:` and words it with macaw_base's `Macaw.Base.Fault.sentence/2`,
passing `root:` along. The words are the caller's `words:` first, a function or a list
of them each answering `nil` for a reason it doesn't word, then format's own,
`Macaw.Format.words/1`, then macaw_base's general words. `what:` names what the input is
not, and starts the message:

    iex> Exception.message(Macaw.Format.Error.exception(reason: {:type, :pattern}, what: "not a time format"))
    "not a time format: must be a strftime pattern, a string"

# `option`

```elixir
@type option() ::
  {:reason, term()}
  | {:what, String.t()}
  | {:root, String.t()}
  | {:words, Macaw.Base.Fault.words() | [Macaw.Base.Fault.words()]}
```

`exception/1`'s options.

# `t`

```elixir
@type t() :: %Macaw.Format.Error{
  __exception__: term(),
  message: String.t(),
  reason: term()
}
```

---

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