fmt::system_error

Constructs std::system_error with a message formatted with fmt::format(fmt, args...). error_code is a system error code as given by errno.

Synopsis

Declared in <fmt/format.h>

template<typename... T>
std::system_error
system_error(
    int error_code,
    format_string<T...> fmt,
    T&&... args);

Description

Example:

// This throws std::system_error with the description // cannot open file 'madeup': No such file or directory // or similar (system message may vary). const char* filename = "madeup"; FILE* file = fopen(filename, "r"); if (!file) throw fmt::system_error(errno, "cannot open file '{}'", filename);

Return Value

The constructed std::system_error.

Parameters

NameDescription
error_codeA system error code as given by errno.
fmtThe format string describing the error.
argsThe arguments to format.