MCPcopy Create free account
hub / github.com/Illation/ETEngine / DisplayError

Function DisplayError

Engine/source/EtCore/Util/WindowsUtil.cpp:22–60  ·  view source on GitHub ↗

--------------------- DisplayError Displays the last error in the winApi. lpszFunction is just an argument that enhances the debug output

Source from the content-addressed store, hash-verified

20// Displays the last error in the winApi. lpszFunction is just an argument that enhances the debug output
21//
22void DisplayError(LPTSTR lpszFunction)
23{
24 LPVOID lpMsgBuf;
25 LPVOID lpDisplayBuf;
26 DWORD dw = GetLastError();
27
28 FormatMessage(
29 FORMAT_MESSAGE_ALLOCATE_BUFFER |
30 FORMAT_MESSAGE_FROM_SYSTEM |
31 FORMAT_MESSAGE_IGNORE_INSERTS,
32 NULL,
33 dw,
34 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
35 (LPTSTR)&lpMsgBuf,
36 0,
37 NULL);
38
39 lpDisplayBuf =
40 (LPVOID)LocalAlloc(LMEM_ZEROINIT,
41 (lstrlen((LPCTSTR)lpMsgBuf)
42 + lstrlen((LPCTSTR)lpszFunction)
43 + 40) // account for format string
44 * sizeof(TCHAR));
45
46 if (FAILED(StringCchPrintf((LPTSTR)lpDisplayBuf,
47 LocalSize(lpDisplayBuf) / sizeof(TCHAR),
48 TEXT("%s failed with error code %d as follows:\n%s"),
49 lpszFunction,
50 dw,
51 lpMsgBuf)))
52 {
53 LOG("FATAL: Unable to output error code", Error);
54 }
55
56 LOG((LPCTSTR)lpDisplayBuf, Error);
57
58 LocalFree(lpMsgBuf);
59 LocalFree(lpDisplayBuf);
60}
61
62//---------------------
63// GetExecutablePathName

Callers 7

OpenMethod · 0.85
CloseMethod · 0.85
GetEntrySizeMethod · 0.85
ReadFileMethod · 0.85
WriteFileMethod · 0.85
DeleteFileMethod · 0.85
CreateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected