Porytiles
Loading...
Searching...
No Matches
porytiles2::ImageLoadError Class Referencefinal

#include <image_load_error.hpp>

Inheritance diagram for porytiles2::ImageLoadError:
[legend]
Collaboration diagram for porytiles2::ImageLoadError:
[legend]

Classes

struct  ChannelCount
 
struct  OtherLoadError
 

Public Types

enum class  Type { file_not_found , unsupported_channel_count , other_load_error }
 

Public Member Functions

 ImageLoadError (Type type, std::string filename, std::variant< std::monostate, ChannelCount, OtherLoadError > params)
 
Type type () const
 
const std::string & filename () const
 
const std::variant< std::monostate, ChannelCount, OtherLoadError > & params () const
 
std::vector< std::string > details (const TextFormatter &formatter) const override
 Returns a formatted multi-line string representation of the error.
 
std::unique_ptr< Errorclone () const override
 Creates a polymorphic copy of this error.
 
- Public Member Functions inherited from porytiles2::Error
virtual ~Error ()=default
 
virtual std::string join (const TextFormatter &formatter, const std::string &delimiter="\n") const
 Joins the error details into a single string with a specified delimiter.
 

Static Public Member Functions

static ImageLoadError file_not_found (const std::string &filename)
 
static ImageLoadError unsupported_channel_count (const std::string &filename, int channel_count)
 
static ImageLoadError other_load_error (const std::string &filename, const std::string &error_msg)
 

Detailed Description

Definition at line 13 of file image_load_error.hpp.

Member Enumeration Documentation

◆ Type

Enumerator
file_not_found 
unsupported_channel_count 
other_load_error 

Definition at line 15 of file image_load_error.hpp.

Constructor & Destructor Documentation

◆ ImageLoadError()

porytiles2::ImageLoadError::ImageLoadError ( Type  type,
std::string  filename,
std::variant< std::monostate, ChannelCount, OtherLoadError params 
)
inline

Definition at line 25 of file image_load_error.hpp.

Member Function Documentation

◆ clone()

std::unique_ptr< Error > porytiles2::ImageLoadError::clone ( ) const
inlineoverridevirtual

Creates a polymorphic copy of this error.

The clone pattern is necessary because ChainableResult stores errors as unique_ptr<Error>, and errors need to be copied when building error chains from const references. Each concrete error type must implement this method to return a new instance with the same state.

Returns
A unique_ptr to a newly allocated copy of this error

Implements porytiles2::Error.

Definition at line 83 of file image_load_error.hpp.

◆ details()

std::vector< std::string > porytiles2::ImageLoadError::details ( const TextFormatter formatter) const
inlineoverridevirtual

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

This method generates a human-readable description of the error, potentially including ANSI formatting codes if the provided TextFormatter indicates TTY output is enabled. Implementations should provide clear, actionable error messages that help users understand what went wrong and potentially how to fix it.

The return value is a vector of strings, where each element represents one line of the error message. Single-line errors return a vector with one element, while multi-line errors can return multiple lines for richer diagnostics.

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

Implements porytiles2::Error.

Definition at line 59 of file image_load_error.hpp.

◆ file_not_found()

static ImageLoadError porytiles2::ImageLoadError::file_not_found ( const std::string &  filename)
inlinestatic

Definition at line 31 of file image_load_error.hpp.

◆ filename()

const std::string & porytiles2::ImageLoadError::filename ( ) const
inline

Definition at line 50 of file image_load_error.hpp.

◆ other_load_error()

static ImageLoadError porytiles2::ImageLoadError::other_load_error ( const std::string &  filename,
const std::string &  error_msg 
)
inlinestatic

Definition at line 41 of file image_load_error.hpp.

◆ params()

const std::variant< std::monostate, ChannelCount, OtherLoadError > & porytiles2::ImageLoadError::params ( ) const
inline

Definition at line 54 of file image_load_error.hpp.

◆ type()

Type porytiles2::ImageLoadError::type ( ) const
inline

Definition at line 46 of file image_load_error.hpp.

◆ unsupported_channel_count()

static ImageLoadError porytiles2::ImageLoadError::unsupported_channel_count ( const std::string &  filename,
int  channel_count 
)
inlinestatic

Definition at line 36 of file image_load_error.hpp.


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