Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Execution/Platform/Windows/Exception.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_Platform_Windows_Exception_h_
5#define _Stroika_Foundation_Execution_Platform_Windows_Exception_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#if qStroika_Foundation_Common_Platform_Windows
10#include <Windows.h>
11#else
12#error "WINDOWS REQUIRED FOR THIS MODULE"
13#endif
14
15#include "Stroika/Foundation/Common/Common.h"
16#include "Stroika/Foundation/Execution/Exceptions.h"
17
19
20 /**
21 * Most Windows (Win32) APIs return a BOOL (or sometimes int) - which if zero (false) means an error. Kinda the opposite of
22 * POSIX APIs.
23 *
24 * These APIS retrieve their underlying error number (when the return value is zero) from ::GetLastError ().
25 *
26 *
27 * This function simplifies use of such functions, trnaslating their results into the appropriate exception (call to Execution::ThrowSystemErrNo)
28 */
29 template <typename WINDOWS_API_RESULT = int>
30 void ThrowIfZeroGetLastError (WINDOWS_API_RESULT test);
31
32 /**
33 * Some Windows APIs return ERROR_SUCCESSS (0) on success, and non-zero on failure (e.g https://docs.microsoft.com/en-us/windows/desktop/api/winreg/nf-winreg-regcreatekeyexa)
34 *
35 * In that case, the function argument contains the Windows error code.
36 */
37 void ThrowIfNotERROR_SUCCESS (DWORD win32ErrCode);
38
39 /**
40 * Some Windows APIs return NO_ERROR (0) on success, and non-zero on failure (e.g https://docs.microsoft.com/en-us/windows/desktop/api/iphlpapi/nf-iphlpapi-getipstatistics)
41 *
42 * In that case, the function argument contains the Windows error code.
43 */
44 void ThrowIfNot_NO_ERROR (DWORD win32ErrCode);
45
46 /**
47 * ShellExecute () has weird idiosyncratic error results, handled by this function.
48 *
49 * @see https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shellexecutea
50 *
51 * \note @todo - this could possibly be reimplemented using a custom error category, but for now it translates its errors to Win32 standard error
52 * numbers and calls ThrowSystemErrNo ()
53 */
54 void ThrowIfShellExecError (HINSTANCE r);
55
56 /**
57 * If you call RegisterDefaultHandler_invalid_parameter at application startup, subsequent calls
58 * to some C-runtime funtions withh invalid parameters will be translated into Platform::Windows::Exception (ERROR_INVALID_PARAMETER)
59 *
60 * @see https://msdn.microsoft.com/en-us/library/a9yf33zb.aspx
61 */
63
64}
65
66/*
67 ********************************************************************************
68 ***************************** Implementation Details ***************************
69 ********************************************************************************
70 */
71#include "Exception.inl"
72
73#endif /*_Stroika_Foundation_Execution_Platform_Windows_Exception_h_*/