MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / MessageFromErrno

Method MessageFromErrno

ProgramLog/error/errno.cpp:5–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "util/strings.hpp"
4
5std::wstring Error::MessageFromErrno(errno_t err)
6{
7 std::wstring str;
8 // fairly reasonable size so that most error messages fit within it.
9 str.resize_and_overwrite(256, [err](wchar_t* data, std::size_t count) -> std::size_t
10 {
11 if (const errno_t strErr = _wcserror_s(data, count + 1, err); strErr == 0)
12 {
13 return wcslen(data);
14 }
15 else
16 {
17 return 0;
18 }
19 });
20
21 if (!str.empty())
22 {
23 Util::TrimInplace(str);
24 }
25 else
26 {
27 str = L"[failed to get message for errno_t]";
28 }
29
30 return std::format(L"{}: {}", err, str);
31}

Callers

nothing calls this directly

Calls 1

TrimInplaceFunction · 0.85

Tested by

no test coverage detected