Skip to content

Commit

Permalink
use InternetGetLastResponseInfoA() for logging internet errors (for #…
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Feb 27, 2023
1 parent 0e78d53 commit cf96cf2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utils/WinUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,17 @@ void LogLastError(DWORD err) {
if (0 == err) {
err = GetLastError();
}

if (err == ERROR_INTERNET_EXTENDED_ERROR) {
char buf[4096] = { 0 };
DWORD bufSize = dimof(buf);
// TODO: ignoring a case where buffer is too small. 4 kB should be enough for everybody
InternetGetLastResponseInfoA(&err, buf, &bufSize);
buf[4095] = 0;
logf("InternetGetLastResponseInfoA: %s\n", buf);
return;
}

char* msgBuf = nullptr;
DWORD flags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
DWORD lang = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
Expand Down

0 comments on commit cf96cf2

Please sign in to comment.