MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetLastErrorAsString

Function GetLastErrorAsString

src/network/core/http_winhttp.cpp:74–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74static std::string GetLastErrorAsString()
75{
76 wchar_t buffer[512];
77
78 DWORD error_code = GetLastError();
79
80 if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_IGNORE_INSERTS, GetModuleHandle(L"winhttp.dll"), error_code,
81 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, static_cast<DWORD>(std::size(buffer)), nullptr) == 0) {
82 return fmt::format("unknown error {}", error_code);
83 }
84
85 return FS2OTTD(buffer);
86}
87
88/**
89 * Callback from the WinHTTP library, called when-ever something changes about the HTTP request status.

Callers 2

WinHttpCallbackMethod · 0.85
ConnectMethod · 0.85

Calls 3

sizeFunction · 0.50
formatFunction · 0.50
FS2OTTDFunction · 0.50

Tested by

no test coverage detected