From d7bb04a09c7f04b0c3a8580d6a9ccd6313656fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 22 Aug 2022 03:17:54 +0200 Subject: Add InternetError exception. --- c/win.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'c/win.h') diff --git a/c/win.h b/c/win.h index ab5cf05..f5bda59 100644 --- a/c/win.h +++ b/c/win.h @@ -16,14 +16,32 @@ int GetRelativeCursorPos(HWND hWnd, POINT* pt) noexcept; /* Cached values from GetSystemMetrics. */ template 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; -- cgit v1.2.3