mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/CrashHandler: Log GetLastError() id if no description is found
Log the System Error id returned by GetLastError() in case FormatMessage() doesn't find a proper description for that message.
This commit is contained in:
@@ -29,15 +29,23 @@
|
||||
inline LPTSTR ErrorMessage(DWORD dw)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0, NULL);
|
||||
return (LPTSTR)lpMsgBuf;
|
||||
DWORD formatResult = FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL,
|
||||
dw,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0, NULL);
|
||||
if (formatResult != 0)
|
||||
return (LPTSTR)lpMsgBuf;
|
||||
else
|
||||
{
|
||||
LPTSTR msgBuf = (LPTSTR)LocalAlloc(LPTR, 30);
|
||||
sprintf(msgBuf, "Unknown error: %u", dw);
|
||||
return msgBuf;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//============================== Global Variables =============================
|
||||
|
||||
Reference in New Issue
Block a user