diff options
Diffstat (limited to 'c/win.h')
-rw-r--r-- | c/win.h | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -16,14 +16,32 @@ int GetRelativeCursorPos(HWND hWnd, POINT* pt) noexcept; /* Cached values from GetSystemMetrics. */ template <int I> auto Metric = GetSystemMetrics(I); +struct WideException : public std::exception +{ + virtual const char* what() const noexcept = 0; + virtual const wchar_t* What() const noexcept = 0; +}; + /* Exception for Windows API errors. */ -struct Win32Error : public std::exception +struct Win32Error : public WideException { - Win32Error() noexcept; - Win32Error(DWORD code) noexcept; + Win32Error(DWORD code = GetLastError()) noexcept; ~Win32Error() noexcept; const char* what() const noexcept override; - const wchar_t* What() const noexcept; + const wchar_t* What() const noexcept override; + DWORD code; +private: + char* m_szMsg = nullptr; + wchar_t* m_wszMsg = nullptr; +}; + +/* Exception for extended Wininet errors. */ +struct InternetError : public WideException +{ + InternetError(DWORD codeSystem = GetLastError()); + ~InternetError() noexcept; + const char* what() const noexcept override; + const wchar_t* What() const noexcept override; DWORD code; private: char* m_szMsg = nullptr; |