From 2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 7 Sep 2022 00:40:26 +0200 Subject: Improve error handling. --- c/window.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'c/window.h') diff --git a/c/window.h b/c/window.h index daf7202..9d247ec 100644 --- a/c/window.h +++ b/c/window.h @@ -15,7 +15,15 @@ struct Window HWND hWnd; HWND hWndFocus = nullptr; HWND hWndStatus = nullptr; - HMENU hMenuPopup = Require(GetSubMenu(Require(LoadMenuW(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU))), 0)); + const HMENU hMenuPopup = []() + { + HMENU hm; + if (!(hm = LoadMenuW(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU)))) + throw Err(WINDOWS, L"Context menu could not be loaded: %s"); + if (!GetSubMenu(hm, 0)) + throw Err(WINDOWS, L"Submenu could not be retrieved: %s"); + return hm; + }(); /* File views. */ FileView fvCfg = FileView::Initialized(L"cfg.dat", 1); -- cgit v1.2.3