Skip to content

Commit

Permalink
Add an error message for obscure win32 errors (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
deplinenoise authored Sep 17, 2021
1 parent 1c9970d commit 39c8633
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ void NORETURN CroakErrno(const char* fmt, ...)
va_end(args);
fprintf(stderr, "\n");
fprintf(stderr, "errno: %d (%s)\n", errno, strerror(errno));
#if defined(TUNDRA_WIN32)
DWORD gle = GetLastError();

char* message = nullptr;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, gle, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&message, 0, NULL);

fprintf(stderr, "Win32 GLE: %u (%s)\n", gle, message);
#endif
if (DebuggerAttached())
abort();
else
Expand Down

0 comments on commit 39c8633

Please sign in to comment.