aboutsummaryrefslogtreecommitdiff
path: root/c/main.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-09-03 15:28:56 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-09-03 15:28:56 +0200
commit6ae7e24675cff4ff6b808c3024f45083f35ced97 (patch)
tree2a47273f325d8367db2a8669691273f02ca83eb9 /c/main.cpp
parent2cd22c671c67deaf2c1fcb659e3262bf57552557 (diff)
downloadEpisodeBrowser-6ae7e24675cff4ff6b808c3024f45083f35ced97.tar.gz
Improve error handling.
Diffstat (limited to 'c/main.cpp')
-rw-r--r--c/main.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/c/main.cpp b/c/main.cpp
index 9e8cee3..f9d4a42 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -126,13 +126,11 @@ static void InitializeMainWindow_(const HWND hWnd)
* initializes global variables that are used by WndProc. */
/* Look up DPI. */
- Act(L"looking up DPI");
if (auto lib = Library::Maybe(L"User32.dll");
auto GetDpiForWindow = lib? lib->GetProcAddress<UINT(HWND)>("GetDpiForWindow"): nullptr)
g_dpi = GetDpiForWindow(hWnd);
/* Load normal font. */
- Act(L"loading fonts");
if (auto lib = Library::Maybe(L"User32.dll");
lib && lib->GetProcAddress<void>("SystemParametersInfoW")) {
NONCLIENTMETRICSW m = {sizeof(NONCLIENTMETRICSW)};
@@ -160,7 +158,6 @@ static void InitializeMainWindow_(const HWND hWnd)
SetWindowTheme = (decltype(SetWindowTheme))(void*)GetProcAddress(hModule, "SetWindowTheme");
}
- Act(L"setting up main window");
g_window = new Window(hWnd);
}
@@ -169,18 +166,17 @@ void InitializeMainWindow(const HWND hWnd) noexcept
try {
InitializeMainWindow_(hWnd);
} catch (...) {
- ShowException(L"Initialization failed due to an error while %s: %s");
+ EBMessageBox(What(), L"Initialization Error", MB_ICONERROR);
exit(1);
}
}
LRESULT CALLBACK WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM lParam)
{
- Act(nullptr);
try {
return g_window->WndProc(hWnd, uMsg, wParam, lParam);
} catch (...) {
- ShowException(L"The action was cancelled due to an error while %s: %s");
+ EBMessageBox(What(), L"Error");
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@@ -223,7 +219,6 @@ LRESULT CALLBACK Window::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM
{
switch (uMsg) {
case WM_CREATE:
- Act(L"creating main window");
UpdateTheme();
SetWindowPos(hWnd, nullptr, -1, -1, Dpi(510), Dpi(412), SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE);
SetFocus(elv.hWnd);