View Source MDEx.DecodeError exception (MDEx v0.2.0)

Represents an error decoding the AST from the Elixir data structure into Rust.

This module is defined as an exception so a message can be generated calling Exception.message/1 or it can be raised.

Fields

  • :reason - an atom representing the type of decode error:

    • :invalid_structure - AST structure is invalid or malformed.

    • :empty - AST is empty, no nodes found.

    • :missing_node_field - one or more fields of a node is missing, it should contain {name, attributes, children}.

    • :missing_attr_field - either the key or value of an attribute is missing.

    • :node_name_not_string - node name is not a UTF-8 encoded string.

    • :unknown_node_name - node name is not one of the available node names.

    • :attr_key_not_string - attribute key is not a UTF-8 encoded string.

    • :unknown_attr_value - attribute value doesn't match any expected type.

  • :found - the source that caused the error, either the node or attribute. Most of the times it's displayed as the raw Term value as a string (debug). That's because the error may be caused by malformed or unexpected data and we can't decode it to a human-readable format.

  • :node - the node where the error was found, usually when the error is in an attribute or children.

  • :attr - the attribute where the error was found.

  • :kind - the type of the field that caused the error.

Summary

Functions

Callback implementation for Exception.message/1.

Types

@type t() :: %MDEx.DecodeError{
  __exception__: true,
  attr: nil | String.t(),
  found: String.t(),
  kind: nil | String.t(),
  node: nil | String.t(),
  reason: atom()
}

Functions

Callback implementation for Exception.message/1.