Expand description
Error display formatting for the CLI.
Error output is written directly to stderr rather than routed through
tracing. A tracing subscriber may suppress output depending on the
configured log level and would add unwanted structure (timestamps, targets,
etc.) to user-facing messages.
The formatting logic lives in write_error<W: Write>, which accepts an
arbitrary writer so tests can capture output without redirecting the
process-global stderr. The public print_error function wires that writer
to stderr. write_error is private; the test submodule accesses it
directly as a child of this module. The eprintln! call in
print_error_with_json is excluded from the no-println lint via the
rule’s ignores list.
Functions§
- print_
error - Prints a user-friendly error message with context and suggestions.
- print_
error_ with_ json - Prints an error message, either as JSON or user-friendly format.