Mojibake.Error exception (Mojibake v0.8.0)

Copy Markdown View Source

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 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.

Summary

Types

reason()

@type reason() :: atom()

t()

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