convertWinApiErrorCodeToMessage#

Fully qualified name: carb::extras::convertWinApiErrorCodeToMessage

Defined in carb/extras/Errors.h

inline std::string carb::extras::convertWinApiErrorCodeToMessage(
WinApiErrorType errorCode,
)#

(Windows only) Converts a Win32 API error code into a human-readable string.

This function translates a Win32 API error code into a human-readable string using the FormatMessageA function.

Note

In some cases, the returned string may have UTF-8 encoding or format specifiers. Use caution when printing this string. For instance, ERROR_BAD_EXE_FORMAT contains "%1".

Warning

This function does not make any guarantees about the current value of GetLastError() or attempts to keep GetLastError() set at the same value; GetLastError() may be modified by this function.

Parameters:

errorCode – the code of the Win API error

Returns:

a human-readable message based on the error code; an errorCode of 0 produces an empty string