From 37e6a3e1d2048af486ddce39124ce3fc9a5a2d8f Mon Sep 17 00:00:00 2001 From: jackpoz Date: Tue, 8 Apr 2014 22:01:56 +0200 Subject: 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. --- .../shared/Debugging/WheatyExceptionReport.cpp | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp index 1afe688c942..3b6bd3d2cc8 100644 --- a/src/server/shared/Debugging/WheatyExceptionReport.cpp +++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp @@ -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 ============================= -- cgit v1.2.3