aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2014-04-08 22:01:56 +0200
committerjackpoz <giacomopoz@gmail.com>2014-04-08 22:01:56 +0200
commit37e6a3e1d2048af486ddce39124ce3fc9a5a2d8f (patch)
tree9ec3f3f9ca98bc3000198285fe075362139d157b /src
parent92a71b45aa11867a80dc4a2eb3cfa5317504fa37 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp26
1 files changed, 17 insertions, 9 deletions
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 =============================