From b2a018ff822bcdb5b9b691025a5fc1eb6fc13b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 7 Sep 2022 00:50:47 +0200 Subject: Don't throw from WinMain. WinMain is noexcept. --- c/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/c/main.cpp b/c/main.cpp index 236b6d3..4fc2fd5 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -64,10 +64,12 @@ int WINAPI WinMain( icc.dwSize = sizeof(icc); icc.dwICC = ICC_WIN95_CLASSES; if (!InitCommonControlsEx(&icc)) - throw Err(WINDOWS, L"Common controls could not be initialized: %s"); + return EBMessageBox(Err(WINDOWS, L"Common controls could not be initialized: %s").what, + L"Initialization Error", MB_ICONERROR), 1; if (CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED) != S_OK) - throw Err(GENERIC, L"COM library could not be initialized"); + return EBMessageBox(L"COM library could not be initialized", + L"Initialization Error", MB_ICONERROR), 1; WNDCLASSEX wc; memset(&wc, 0, sizeof(WNDCLASSEX)); @@ -81,7 +83,8 @@ int WINAPI WinMain( wc.lpszClassName = L"Episode Browser"; wc.hIconSm = LoadIconW(nullptr, IDI_APPLICATION); if (!RegisterClassExW(&wc)) - throw Err(WINDOWS, L"Window class could not be registered: %s"); + return EBMessageBox(Err(WINDOWS, L"Window class could not be registered: %s").what, + L"Initialization Error", MB_ICONERROR), 1; /* InitializeMainWindow is called before the first message is * sent to WndProc. This is important, as it initializes @@ -95,7 +98,8 @@ int WINAPI WinMain( WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN, XMAIN, YMAIN, 0, 0, nullptr, nullptr, hInstance, nullptr))) - throw Err(WINDOWS, L"Main window could not be created: %s"); + return EBMessageBox(Err(WINDOWS, L"Main window could not be created: %s").what, + L"Initialization Error", MB_ICONERROR), 1; if (!(g_window->hWndStatus = CreateWindowExW( 0, @@ -104,7 +108,8 @@ int WINAPI WinMain( WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, 0, 0, 0, 0, hWnd, reinterpret_cast(IDR_STATUS), hInstance, nullptr))) - throw Err(WINDOWS, L"Status bar could not be created: %s"); + return EBMessageBox(Err(WINDOWS, L"Status bar could not be created: %s").what, + L"Initialization Error", MB_ICONERROR), 1; ShowWindow(hWnd, nCmdShow); -- cgit v1.2.3