Error utilities for DprintMarkdownFormatter.
This module provides validation errors and helper functions for creating standard Elixir exceptions with descriptive messages.
Summary
Functions
Creates an argument error for configuration issues.
Creates a runtime error for formatting failures.
Creates a runtime error for NIF failures.
Creates a runtime error for parsing failures.
Creates a validation error.
Types
@type t() :: DprintMarkdownFormatter.Error.ValidationError.t()
Functions
@spec config_error( String.t(), keyword() ) :: Exception.t()
Creates an argument error for configuration issues.
@spec format_error( String.t(), keyword() ) :: Exception.t()
Creates a runtime error for formatting failures.
@spec nif_error( String.t(), keyword() ) :: Exception.t()
Creates a runtime error for NIF failures.
Used when the Rust NIF returns an error during markdown formatting.
Examples
iex> DprintMarkdownFormatter.Error.nif_error("NIF formatting failed")
%RuntimeError{message: "NIF formatting failed"}
iex> DprintMarkdownFormatter.Error.nif_error("NIF error", original_error: "Invalid markdown syntax")
%RuntimeError{message: "NIF error: Invalid markdown syntax"}
@spec parse_error( String.t(), keyword() ) :: Exception.t()
Creates a runtime error for parsing failures.
Used when Elixir code parsing fails, such as when processing module attributes.
Examples
iex> DprintMarkdownFormatter.Error.parse_error("Failed to parse code")
%RuntimeError{message: "Failed to parse code"}
iex> original_error = %SyntaxError{message: "unexpected token"}
iex> DprintMarkdownFormatter.Error.parse_error("Parse failed", original_error: original_error)
%RuntimeError{message: "Parse failed: %SyntaxError{message: \"unexpected token\"}"}
@spec validation_error( String.t(), keyword() ) :: DprintMarkdownFormatter.Error.ValidationError.t()
Creates a validation error.