xref: /reactos/sdk/lib/atl/atlexcept.h (revision 8a978a17)
1 
2 #ifndef __ATLEXCEPT_H__
3 #define __ATLEXCEPT_H__
4 
5 
6 #ifdef _ATL_NO_EXCEPTIONS
7 #if !defined(STATUS_NO_MEMORY) && defined(WIN32_NO_STATUS)
8 #define STATUS_NO_MEMORY ((DWORD)0xC0000017)
9 #endif
10 #endif
11 
12 namespace ATL
13 {
14 
15 
16 //FIXME: Enable when RaiseException is marked as NORETURN
17 //DECLSPEC_NORETURN
18 inline void AtlThrowImp(HRESULT hr)
19 {
20 #ifdef ATLTRACE
21     ATLTRACE(hr);
22 #endif
23 
24 #ifdef _ATL_NO_EXCEPTIONS
25 
26     ATLASSERT(false);
27 
28     RaiseException(
29         hr == E_OUTOFMEMORY ? STATUS_NO_MEMORY : EXCEPTION_ILLEGAL_INSTRUCTION,
30         EXCEPTION_NONCONTINUABLE, 0, NULL
31         );
32 
33 #else
34 
35     // FIXME: This is horribly wrong, we should implement CException!
36     throw;
37 
38 #endif
39 
40 }
41 
42 
43 #ifndef AtlThrow
44 #define AtlThrow(x) AtlThrowImp(x)
45 #endif
46 
47 
48 }; // namespace ATL
49 
50 #endif
51