Raxol.CLI.ErrorFormatter (Raxol v2.6.0)

View Source

Formats ErrorExperience suggestions for CLI output.

Bridges the sophisticated error analysis from Raxol.Core.ErrorExperience to user-friendly CLI output using the Raxol.CLI.Colors palette.

Usage

# Format and display an error with suggestions
ErrorFormatter.format_error(error, context)

# Get formatted string without printing
output = ErrorFormatter.to_string(error, context)

# Use in Mix tasks
case compile_project() do
  {:error, reason} ->
    ErrorFormatter.format_error(reason, %{task: :compile})
    Mix.raise("Compilation failed")
  :ok -> :ok
end

Summary

Functions

Formats an already-enhanced error structure.

Formats and prints an error with intelligent suggestions.

Returns formatted error string without printing.

Functions

format_enhanced(enhanced_error)

@spec format_enhanced(Raxol.Core.ErrorExperience.enhanced_error()) :: :ok

Formats an already-enhanced error structure.

format_error(error, context \\ %{})

@spec format_error(term(), map()) :: :ok

Formats and prints an error with intelligent suggestions.

Analyzes the error, generates suggestions, and displays them in a user-friendly CLI format.

to_string(error, context \\ %{})

@spec to_string(term(), map()) :: String.t()

Returns formatted error string without printing.