|
1
|
1 #include "stdafx.h"
|
|
|
2 #include "win32_op.h"
|
|
|
3 #include <assert.h>
|
|
|
4
|
|
|
5 PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL() {
|
|
|
6 const DWORD code = GetLastError();
|
|
|
7 PFC_ASSERT(code != NO_ERROR);
|
|
|
8 throw exception_win32(code);
|
|
|
9 }
|
|
|
10
|
|
|
11 PFC_NORETURN PFC_NOINLINE void WIN32_OP_FAIL_CRITICAL(const char * what) {
|
|
|
12 (void)what;
|
|
|
13 #if PFC_DEBUG
|
|
|
14 const DWORD code = GetLastError();
|
|
|
15 PFC_ASSERT(code != NO_ERROR);
|
|
|
16 #endif
|
|
|
17 pfc::crash();
|
|
|
18 #if 0
|
|
|
19 pfc::string_formatter msg; msg << what << " failure #" << (uint32_t)code;
|
|
|
20 TRACK_CODE(msg.get_ptr(), uBugCheck());
|
|
|
21 #endif
|
|
|
22 }
|
|
|
23
|
|
|
24 #if PFC_DEBUG
|
|
|
25 void WIN32_OP_D_FAIL(const wchar_t * _Message, const wchar_t *_File, unsigned _Line) {
|
|
|
26 const DWORD code = GetLastError();
|
|
|
27 pfc::array_t<wchar_t> msgFormatted; msgFormatted.set_size(pfc::strlen_t(_Message) + 64);
|
|
|
28 wsprintfW(msgFormatted.get_ptr(), L"%s (code: %u)", _Message, code);
|
|
|
29 if (IsDebuggerPresent()) {
|
|
|
30 OutputDebugString(TEXT("WIN32_OP_D() failure:\n"));
|
|
|
31 OutputDebugString(msgFormatted.get_ptr());
|
|
|
32 OutputDebugString(TEXT("\n"));
|
|
|
33 pfc::crash();
|
|
|
34 }
|
|
|
35 _wassert(msgFormatted.get_ptr(), _File, _Line);
|
|
|
36 }
|
|
|
37 #endif
|