MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / get_win32_error_msg

Function get_win32_error_msg

src/common/Win32Exception.cpp:30–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28};
29
30std::string get_win32_error_msg(DWORD error_code) {
31 std::unique_ptr<wchar_t[], LocalFreeHelper> buff;
32 LPWSTR buf_ptr = nullptr;
33 DWORD buf_len = 0;
34 if (error_code >= INTERNET_ERROR_BASE && error_code <= INTERNET_ERROR_LAST) {
35 buf_len = ::FormatMessageW(
36 FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, GetModuleHandle(L"wininet.dll"),
37 error_code, 0, reinterpret_cast<LPWSTR>(&buf_ptr), 0, nullptr);
38 } else {
39 assert(false); // unsupported
40 }
41 buff.reset(buf_ptr);
42 auto str = to_utf8_string({buff.get(), buf_len});
43 return str;
44}
45
46} // namespace
47

Callers 1

throw_if_errorFunction · 0.85

Calls 3

to_utf8_stringFunction · 0.85
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected