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

General-purpose error implementation with formatted message support. More...

#include <error.hpp>

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

Public Member Functions

 FormattableError ()=default
 
 FormattableError (std::string text)
 
 FormattableError (std::string text, std::vector< FormatParam > params)
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_same_v<std::decay_t<FirstParam>, FormatParam> && (std::is_same_v<std::decay_t<RestParams>, FormatParam> && ...))
 FormattableError (std::string text, FirstParam &&first, RestParams &&...rest)
 
 FormattableError (std::vector< std::string > lines)
 
 FormattableError (std::vector< std::string > lines, std::vector< std::vector< FormatParam > > params)
 
std::vector< std::string > details (const TextFormatter &formatter) const override
 Returns a formatted multi-line string representation of the error.
 
bool has_details () const
 
std::unique_ptr< Errorclone () const override
 
- Public Member Functions inherited from porytiles::Error
virtual ~Error ()=default
 
virtual std::string join (const TextFormatter &formatter, const std::string &delimiter="\n") const
 

Detailed Description

General-purpose error implementation with formatted message support.

FormattableError is a concrete Error implementation for common error scenarios where a specialized error type would be unnecessary overhead. It supports plain string messages, format strings with styled FormatParam substitution, and multi-line error messages. TTY-aware styling is handled automatically through TextFormatter.

Definition at line 63 of file error.hpp.

Constructor & Destructor Documentation

◆ FormattableError() [1/6]

porytiles::FormattableError::FormattableError ( )
default

◆ FormattableError() [2/6]

porytiles::FormattableError::FormattableError ( std::string  text)
inlineexplicit

Definition at line 67 of file error.hpp.

◆ FormattableError() [3/6]

porytiles::FormattableError::FormattableError ( std::string  text,
std::vector< FormatParam params 
)
inlineexplicit

Definition at line 74 of file error.hpp.

◆ FormattableError() [4/6]

template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_same_v<std::decay_t<FirstParam>, FormatParam> && (std::is_same_v<std::decay_t<RestParams>, FormatParam> && ...))
porytiles::FormattableError::FormattableError ( std::string  text,
FirstParam &&  first,
RestParams &&...  rest 
)
inlineexplicit

Definition at line 87 of file error.hpp.

◆ FormattableError() [5/6]

porytiles::FormattableError::FormattableError ( std::vector< std::string >  lines)
inlineexplicit

Definition at line 98 of file error.hpp.

◆ FormattableError() [6/6]

porytiles::FormattableError::FormattableError ( std::vector< std::string >  lines,
std::vector< std::vector< FormatParam > >  params 
)
inlineexplicit

Definition at line 100 of file error.hpp.

Member Function Documentation

◆ clone()

std::unique_ptr< Error > porytiles::FormattableError::clone ( ) const
inlineoverridevirtual

Implements porytiles::Error.

Definition at line 132 of file error.hpp.

◆ details()

std::vector< std::string > porytiles::FormattableError::details ( const TextFormatter formatter) const
inlineoverridevirtual

Returns a formatted multi-line string representation of the error.

Each element in the returned vector represents one line of the error message. The TextFormatter controls whether ANSI styling codes are included based on TTY status.

Parameters
formatterThe TextFormatter to use for conditional formatting based on TTY status
Returns
A vector of formatted strings describing the error, one per line

Implements porytiles::Error.

Definition at line 105 of file error.hpp.

◆ has_details()

bool porytiles::FormattableError::has_details ( ) const
inline

Definition at line 122 of file error.hpp.


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