# `Nous.Errors.Base`
[🔗](https://github.com/nyo16/nous/blob/v0.17.1/lib/nous/errors/base.ex#L1)

Shared construction for Nous exception modules.

`use Nous.Errors.Base, fields: [...]` generates the `defexception` and the
two `exception/1` clauses every Nous error shares: a keyword form taking
the declared fields plus an optional `:message` override, and a bare-binary
message form.

The using module supplies a private `default_message/1`, which receives the
map of declared fields and returns the message used when `:message` is not
given.

    defmodule MyError do
      use Nous.Errors.Base, fields: [:reason]

      @type t :: %__MODULE__{message: String.t(), reason: String.t() | nil}

      defp default_message(%{reason: reason}) do
        "It broke" <> if(reason, do: ": #{reason}", else: "")
      end
    end

---

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