# `Mojibake.Error`
[🔗](https://github.com/zaerl/mojibake/blob/main/src/elixir/lib/mojibake/error.ex#L5)

An error reported by Mojibake.

Functions that can fail return `{:error, %Mojibake.Error{}}`; their `!` variants raise it.

`reason` is one of:

  * `:malformed_input` - the input is not well-formed UTF-8 and the `:malformed` option is
    `:stop`. `offset` and `length` give the byte range of the first ill-formed subsequence and
    `detail` says what is wrong with it, for example `:missing_continuation`.
  * `:invalid_locale` - a BCP 47 language tag, such as the `:locale` option, is not
    well-formed.
  * `:invalid_domain` - `Mojibake.IDNA` found the domain name invalid. `detail` is the list of
    `t:Mojibake.IDNA.error/0`.
  * `:no_memory` - the C library could not allocate memory.
  * `:overflow` - a size computation overflowed.
  * any other `mjb_status` of the C library, as an atom: `:invalid_argument`,
    `:invalid_encoding`, `:invalid_codepoint`, `:invalid_form`, `:unsupported`,
    `:output_too_small`, `:callback_stopped`, `:not_found`, `:feature_not_enabled`, or
    `:end_of_input`.

# `reason`

```elixir
@type reason() :: atom()
```

# `t`

```elixir
@type t() :: %Mojibake.Error{
  __exception__: term(),
  detail: atom() | [atom()] | nil,
  length: non_neg_integer() | nil,
  offset: non_neg_integer() | nil,
  reason: reason()
}
```

---

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