Error types¶
The following types form a taxonomy of all the possible errors that BLACK can
return to the user. These types are not thrown as exceptions, but returned
as the error component of a std::expected object. This
ensures they are always handled explicitly.
-
struct error¶
(Non-polymorphic) base class for all the following error classes.
Subclassed by black::support::io_error, black::support::syntax_error
Public Functions
Public Members
-
std::string message¶
The error message.
-
std::string message¶
-
struct syntax_error : public black::support::error¶
A syntax error occurred in any input file read by BLACK.
Public Functions
-
template<typename ...Args>
inline syntax_error(std::optional<std::string> filename, size_t line, size_t column, const char *format, Args const&... args)¶ - Parameters:
filename – The filename (see
filenamebelow).line – The error line.
column – The error column.
format – A format string (see
std::format) for the error message.args – The format string arguments.
Public Members
-
std::optional<std::string> filename¶
The name of the file where the syntax error occurred. If
filenameisstd::nullopt, the error came from some source different from a file (e.g. the standard input stream).
-
size_t line = 0¶
The line where the syntax error occurred.
-
size_t column = 0¶
The column where the syntax error occurred.
-
template<typename ...Args>
-
struct io_error : public black::support::error¶
An error occurred while reading or writing from files or streams.
Public Types
Public Functions
-
template<typename ...Args>
inline io_error(std::optional<std::string> filename, operation op, int err, const char *format, Args const&... args)¶ - Parameters:
filename – The filename (see
filenamebelow).op – The kind of operation that caused the error.
err – The value of the
errnovariable describing the error.format – A format string (see
std::format) for the error message.args – The format string arguments.
-
template<typename ...Args>