50 [[nodiscard]]
const std::string &
filename()
const
54 [[nodiscard]]
const std::variant<std::monostate, ChannelCount, OtherLoadError> &
params()
const
67 auto channel_count = std::get<ChannelCount>(params_).channel_count_;
69 " unsupported channel count: " + formatter.
style(std::to_string(channel_count),
Style::bold);
73 auto load_error = std::get<OtherLoadError>(params_).load_error_;
74 message = formatter.
style(filename_ +
":",
Style::bold) +
" could not be loaded: '" + load_error +
"'";
78 panic(
"unhandled ImageLoadError type");
83 [[nodiscard]] std::unique_ptr<Error>
clone()
const override
85 return std::make_unique<ImageLoadError>(this->type_, this->filename_, this->params_);
90 std::string filename_;
91 std::variant<std::monostate, ChannelCount, OtherLoadError> params_;
Abstract interface for all error types used in ChainableResult error chains.
const std::string & filename() const
std::vector< std::string > details(const TextFormatter &formatter) const override
Returns a formatted multi-line string representation of the error.
const std::variant< std::monostate, ChannelCount, OtherLoadError > & params() const
static ImageLoadError other_load_error(const std::string &filename, const std::string &error_msg)
@ unsupported_channel_count
static ImageLoadError file_not_found(const std::string &filename)
std::unique_ptr< Error > clone() const override
Creates a polymorphic copy of this error.
static ImageLoadError unsupported_channel_count(const std::string &filename, int channel_count)
ImageLoadError(Type type, std::string filename, std::variant< std::monostate, ChannelCount, OtherLoadError > params)
Abstract base class for applying text styling with context-aware formatting.
virtual std::string style(const std::string &text, Style styles) const =0
Applies styling to a text string.
void panic(const StringViewSourceLoc &s)
Unconditionally terminates the program with a panic message.
@ bold
Bold text formatting.