diff options
author | John Ankarström <john@ankarstrom.se> | 2022-09-03 15:28:56 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-09-03 15:28:56 +0200 |
commit | 6ae7e24675cff4ff6b808c3024f45083f35ced97 (patch) | |
tree | 2a47273f325d8367db2a8669691273f02ca83eb9 /c/win32.h | |
parent | 2cd22c671c67deaf2c1fcb659e3262bf57552557 (diff) | |
download | EpisodeBrowser-6ae7e24675cff4ff6b808c3024f45083f35ced97.tar.gz |
Improve error handling.
Diffstat (limited to 'c/win32.h')
-rw-r--r-- | c/win32.h | 15 |
1 files changed, 4 insertions, 11 deletions
@@ -6,6 +6,8 @@ #include <windows.h> #include <commctrl.h> +#include "err.h" + /* Convert narrow to wide string. */ std::wstring WideFromNarrow(const std::string_view src, const int cp = CP_UTF8); @@ -13,16 +15,7 @@ std::wstring WideFromNarrow(const std::string_view src, const int cp = CP_UTF8); void WithNextWindow(void (*proc)(HWND)); /* Display message box centered in main window. */ -int EBMessageBox(std::wstring_view text, std::wstring_view data, UINT uType); - -/* Specify current action (used by ShowException). */ -void Act(const wchar_t* action); - -/* Show message box for current exception. */ -void ShowException( - const wchar_t* fmt = L"An error occurred: %s", - const wchar_t* title = L"Error", - UINT uType = MB_ICONWARNING) noexcept; +int EBMessageBox(std::wstring_view text, std::wstring_view data, UINT uType = MB_ICONWARNING); /* Retrieve mouse position relative to given window's client area. */ int GetRelativeCursorPos(HWND hWnd, POINT* pt) noexcept; @@ -89,7 +82,7 @@ T* Library::GetProcAddress(const char* const szProc) noexcept template <typename T> inline T Require(const T x) { - if (!x) throw Win32Error(); + if (!x) Err(WINDOWS, L"System error: %s"); return x; } |