From 6ae7e24675cff4ff6b808c3024f45083f35ced97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 3 Sep 2022 15:28:56 +0200 Subject: Improve error handling. --- c/win32.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'c/win32.h') diff --git a/c/win32.h b/c/win32.h index a88e97c..c18e70f 100644 --- a/c/win32.h +++ b/c/win32.h @@ -6,6 +6,8 @@ #include #include +#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 inline T Require(const T x) { - if (!x) throw Win32Error(); + if (!x) Err(WINDOWS, L"System error: %s"); return x; } -- cgit v1.2.3