diff options
author | John Ankarström <john@ankarstrom.se> | 2022-09-07 00:50:47 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-09-07 01:04:36 +0200 |
commit | b2a018ff822bcdb5b9b691025a5fc1eb6fc13b4b (patch) | |
tree | 4a0ab66372fe2cb76a2efa7534e62f13bc3115ec | |
parent | 2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160 (diff) | |
download | EpisodeBrowser-b2a018ff822bcdb5b9b691025a5fc1eb6fc13b4b.tar.gz |
Don't throw from WinMain.
WinMain is noexcept.
-rw-r--r-- | c/main.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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<HMENU>(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); |