Porytiles
Loading...
Searching...
No Matches
porytiles2::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 porytiles2::StderrStyledUserDiagnostics:
[legend]
Collaboration diagram for porytiles2::StderrStyledUserDiagnostics:
[legend]

Public Member Functions

 StderrStyledUserDiagnostics (const gsl::not_null< TextFormatter * > format)
 
void note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged informational note to stderr.
 
void warn_note (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged warning note to stderr.
 
void warn (const std::string &tag, const std::vector< std::string > &lines) const override
 Display a multi-line tagged warning to stderr.
 
void err (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.
 
- Public Member Functions inherited from porytiles2::UserDiagnostics
virtual ~UserDiagnostics ()=default
 
void note (const std::string &tag, const std::string &msg) const
 Display a tagged informational note message.
 
void warn_note (const std::string &tag, const std::string &msg) const
 Display a note message with a warning tag.
 
void warn (const std::string &tag, const std::string &msg) const
 Display a tagged warning message.
 
void err (const std::string &tag, const std::string &msg) const
 Display a tagged error message.
 
template<typename T , typename E >
void fatal (const ChainableResult< T, E > &result) const
 Display a fatal error with complete error chain visualization.
 

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 38 of file stderr_styled_user_diagnostics.hpp.

Constructor & Destructor Documentation

◆ StderrStyledUserDiagnostics()

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

Definition at line 40 of file stderr_styled_user_diagnostics.hpp.

Member Function Documentation

◆ emit_fatal_proximate()

void porytiles2::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 porytiles2::UserDiagnostics.

Definition at line 61 of file stderr_styled_user_diagnostics.cpp.

◆ emit_fatal_root()

void porytiles2::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 porytiles2::UserDiagnostics.

Definition at line 93 of file stderr_styled_user_diagnostics.cpp.

◆ emit_fatal_step()

void porytiles2::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 porytiles2::UserDiagnostics.

Definition at line 78 of file stderr_styled_user_diagnostics.cpp.

◆ err()

void porytiles2::StderrStyledUserDiagnostics::err ( 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 porytiles2::UserDiagnostics.

Definition at line 50 of file stderr_styled_user_diagnostics.cpp.

◆ note()

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

Display a multi-line tagged informational note 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.

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

Implements porytiles2::UserDiagnostics.

Definition at line 13 of file stderr_styled_user_diagnostics.cpp.

◆ warn()

void porytiles2::StderrStyledUserDiagnostics::warn ( 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 porytiles2::UserDiagnostics.

Definition at line 39 of file stderr_styled_user_diagnostics.cpp.

◆ warn_note()

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

Display a multi-line tagged warning note to stderr.

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

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

Implements porytiles2::UserDiagnostics.

Definition at line 28 of file stderr_styled_user_diagnostics.cpp.


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