Porytiles
Loading...
Searching...
No Matches
porytiles::StderrStyledUserDiagnostics Class Referencefinal

Concrete implementation of UserDiagnostics that outputs structured messages to stderr, optionally with colored formatting. More...

#include <stderr_styled_user_diagnostics.hpp>

Inheritance diagram for porytiles::StderrStyledUserDiagnostics:
[legend]
Collaboration diagram for porytiles::StderrStyledUserDiagnostics:
[legend]

Public Member Functions

 StderrStyledUserDiagnostics (const gsl::not_null< TextFormatter * > format)
 
void remark (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged informational remark to stderr.
 
void warning (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged warning to stderr.
 
void error (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged error message to stderr.
 
void emit_fatal_proximate (const Error &err) const override
 Emit the proximate (immediate) error in a fatal error chain to stderr.
 
void emit_fatal_step (const Error &err) const override
 Emit an intermediate step error in a fatal error chain to stderr.
 
void emit_fatal_root (const Error &err) const override
 Emit the root cause error in a fatal error chain to stderr.
 
void remark_note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged note associated with a remark to stderr.
 
void warning_note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged note associated with a warning to stderr.
 
void error_note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged note associated with an error to stderr.
 
- Public Member Functions inherited from porytiles::UserDiagnostics
virtual ~UserDiagnostics ()=default
 
 UserDiagnostics (gsl::not_null< const TextFormatter * > format)
 
void remark (const std::string &tag, const std::string &msg) const
 Convenience overload for single line messages.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
void remark (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Variadic template overload for formatted remark messages.
 
void warning (const std::string &tag, const std::string &msg) const
 Convenience overload for single line messages.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
void warning (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Variadic template overload for formatted warning messages.
 
void error (const std::string &tag, const std::string &msg) const
 Convenience overload for single line messages.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
void error (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Variadic template overload for formatted error messages.
 
void remark_note (const std::string &tag, const std::string &msg) const
 Convenience overload for single line messages.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
void remark_note (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Variadic template overload for formatted remark note messages.
 
void warning_note (const std::string &tag, const std::string &msg) const
 Convenience overload for single line messages.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
void warning_note (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Variadic template overload for formatted warning note messages.
 
void error_note (const std::string &tag, const std::string &msg) const
 Convenience overload for single line messages.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
void error_note (const std::string &tag, const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Variadic template overload for formatted error note messages.
 
template<typename T , typename E >
void fatal (const ChainableResult< T, E > &result) const
 Display a fatal error with complete error chain visualization.
 
const TextFormatterformatter () const
 

Detailed Description

Concrete implementation of UserDiagnostics that outputs structured messages to stderr, optionally with colored formatting.

StderrStyledUserDiagnostics provides a terminal-based implementation of the UserDiagnostics interface. It outputs all diagnostic messages to stderr with some additional pretty-print structuring. If provided with an AnsiStyledTextFormatter, it will additionally use canonical diagnostic coloring and styling (canonical, i.e. magenta for warnings, red for errors, bolding where appropriate, etc.) via ANSI terminal codes. The implementation includes:

  • Colored Output: Uses ANSI codes for terminal colors (cyan for notes, magenta for warnings, red for errors)
  • Multi-line Support: First line gets the appropriate prefix, subsequent lines are indented with visual guidelines to aid reading
  • Error Chain Visualization: Fatal errors are displayed with tree-like formatting using Unicode box-drawing characters to show error hierarchy

Definition at line 30 of file stderr_styled_user_diagnostics.hpp.

Constructor & Destructor Documentation

◆ StderrStyledUserDiagnostics()

porytiles::StderrStyledUserDiagnostics::StderrStyledUserDiagnostics ( const gsl::not_null< TextFormatter * >  format)
inlineexplicit

Definition at line 32 of file stderr_styled_user_diagnostics.hpp.

Member Function Documentation

◆ emit_fatal_proximate()

void porytiles::StderrStyledUserDiagnostics::emit_fatal_proximate ( const Error err) const
overridevirtual

Emit the proximate (immediate) error in a fatal error chain to stderr.

Displays the most immediate error in a fatal error chain with red "fatal:" prefix and the highest visual prominence. This represents the direct cause of the failure.

Parameters
errThe proximate error to display

Implements porytiles::UserDiagnostics.

Definition at line 59 of file stderr_styled_user_diagnostics.cpp.

◆ emit_fatal_root()

void porytiles::StderrStyledUserDiagnostics::emit_fatal_root ( const Error err) const
overridevirtual

Emit the root cause error in a fatal error chain to stderr.

Displays the root cause error in a fatal error chain using tree-like formatting with Unicode box-drawing characters (└ symbols). This represents the original underlying cause of the failure and appears as the final item in the error hierarchy visualization.

Parameters
errThe root cause error to display

Implements porytiles::UserDiagnostics.

Definition at line 87 of file stderr_styled_user_diagnostics.cpp.

◆ emit_fatal_step()

void porytiles::StderrStyledUserDiagnostics::emit_fatal_step ( const Error err) const
overridevirtual

Emit an intermediate step error in a fatal error chain to stderr.

Displays intermediate errors in a fatal error chain using tree-like formatting with Unicode box-drawing characters (├ symbols). These represent the intermediate causes between the proximate and root errors in the failure chain.

Parameters
errThe step error to display

Implements porytiles::UserDiagnostics.

Definition at line 72 of file stderr_styled_user_diagnostics.cpp.

◆ error()

void porytiles::StderrStyledUserDiagnostics::error ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged error message to stderr.

Outputs error messages with red "error:" prefix and tag suffix on the first line, formatted as "error: <message> [<tag>]" with appropriate indentation for subsequent lines.

Parameters
tagCategorization tag for the error
linesVector of strings representing each line of the error

Implements porytiles::UserDiagnostics.

Definition at line 44 of file stderr_styled_user_diagnostics.cpp.

◆ error_note()

void porytiles::StderrStyledUserDiagnostics::error_note ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged note associated with an error to stderr.

Outputs informational messages with cyan "note:" prefix and tag suffix on the first line, formatted as "note: <message> [<tag>]" with appropriate indentation for subsequent lines. Uses identical styling to remark_note and warning_note since notes are informational regardless of parent diagnostic type.

Parameters
tagCategorization tag for the note (should match the parent error's tag)
linesVector of strings representing each line of the note

Implements porytiles::UserDiagnostics.

Definition at line 112 of file stderr_styled_user_diagnostics.cpp.

◆ remark()

void porytiles::StderrStyledUserDiagnostics::remark ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged informational remark to stderr.

Outputs informational messages with blue "remark:" prefix and tag suffix on the first line, formatted as "remark: <message> [<tag>]" with appropriate indentation for subsequent lines.

Parameters
tagCategorization tag for the remark
linesVector of strings representing each line of the remark

Implements porytiles::UserDiagnostics.

Definition at line 13 of file stderr_styled_user_diagnostics.cpp.

◆ remark_note()

void porytiles::StderrStyledUserDiagnostics::remark_note ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged note associated with a remark to stderr.

Outputs informational messages with cyan "note:" prefix and tag suffix on the first line, formatted as "note: <message> [<tag>]" with appropriate indentation for subsequent lines. Uses identical styling to warning_note and error_note since notes are informational regardless of parent diagnostic type.

Parameters
tagCategorization tag for the note (should match the parent remark's tag)
linesVector of strings representing each line of the note

Implements porytiles::UserDiagnostics.

Definition at line 102 of file stderr_styled_user_diagnostics.cpp.

◆ warning()

void porytiles::StderrStyledUserDiagnostics::warning ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged warning to stderr.

Outputs warnings with magenta "warning:" prefix and tag suffix on the first line, formatted as "warning: <message> [<tag>]" with appropriate indentation for subsequent lines.

Parameters
tagCategorization tag for the warning
linesVector of strings representing each line of the warning

Implements porytiles::UserDiagnostics.

Definition at line 28 of file stderr_styled_user_diagnostics.cpp.

◆ warning_note()

void porytiles::StderrStyledUserDiagnostics::warning_note ( const std::string &  tag,
const std::vector< std::string > &  lines 
) const
overridevirtual

Display a multi-line tagged note associated with a warning to stderr.

Outputs informational messages with cyan "note:" prefix and tag suffix on the first line, formatted as "note: <message> [<tag>]" with appropriate indentation for subsequent lines. Uses identical styling to remark_note and error_note since notes are informational regardless of parent diagnostic type.

Parameters
tagCategorization tag for the note (should match the parent warning's tag)
linesVector of strings representing each line of the note

Implements porytiles::UserDiagnostics.

Definition at line 107 of file stderr_styled_user_diagnostics.cpp.


The documentation for this class was generated from the following files: