aboutsummaryrefslogtreecommitdiff
path: root/c/win.h
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-22 03:17:54 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-22 03:21:52 +0200
commitd7bb04a09c7f04b0c3a8580d6a9ccd6313656fcf (patch)
tree46f91cf658a39015d821d19935b6f99867ddbfed /c/win.h
parentba0750ff48bcf97ef99602fe27322fa706a93b6b (diff)
downloadEpisodeBrowser-d7bb04a09c7f04b0c3a8580d6a9ccd6313656fcf.tar.gz
Add InternetError exception.
Diffstat (limited to 'c/win.h')
-rw-r--r--c/win.h26
1 files changed, 22 insertions, 4 deletions
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 <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;