mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-14 13:07:54 +00:00
[common] windebug: handle FormatMessage failure
This commit is contained in:
parent
e05bb196f0
commit
8514f35474
1 changed files with 8 additions and 2 deletions
|
@ -18,13 +18,14 @@
|
|||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/windebug.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void DebugWinError(const char * file, const unsigned int line, const char * function, const char * desc, HRESULT status)
|
||||
{
|
||||
char *buffer;
|
||||
FormatMessageA(
|
||||
if (!FormatMessageA(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
status,
|
||||
|
@ -32,7 +33,12 @@ void DebugWinError(const char * file, const unsigned int line, const char * func
|
|||
(char*)&buffer,
|
||||
1024,
|
||||
NULL
|
||||
);
|
||||
))
|
||||
{
|
||||
DEBUG_ERROR("FormatMessage failed with code 0x%08lx", GetLastError());
|
||||
fprintf(stderr, "%12" PRId64 " [E] %20s:%-4u | %-30s | %s: 0x%08x\n", microtime(), file, line, function, desc, (int)status);
|
||||
return;
|
||||
}
|
||||
|
||||
for(size_t i = strlen(buffer) - 1; i > 0; --i)
|
||||
if (buffer[i] == '\n' || buffer[i] == '\r')
|
||||
|
|
Loading…
Reference in a new issue