# `Macaw.Units.Error`
[🔗](https://github.com/dcoai/macaw_units/blob/v0.1.0/lib/macaw/units/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, so a caller that catches nothing
still reads the term in a crash report, and a test asserts it without parsing words:

    iex> error = Macaw.Units.Error.exception(reason: {:unknown_atom, "sec"})
    iex> {error.reason, Exception.message(error)}
    {{:unknown_atom, "sec"}, ~s|"sec" is not a UCUM unit this vocabulary reads|}

`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 units' own,
`Macaw.Units.Unit.format_error/1`, which words every reason. `what:` names what the
input is not, and starts the message:

    iex> Exception.message(Macaw.Units.Error.exception(reason: :empty, what: "not a unit"))
    "not a unit: a unit code is not empty"

# `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.Units.Error{
  __exception__: term(),
  message: String.t(),
  reason: term()
}
```

---

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