| 72 | } |
| 73 | |
| 74 | static 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. |
no test coverage detected