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/ext.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'c/ext.cpp') diff --git a/c/ext.cpp b/c/ext.cpp index ea6718a..ab47ab4 100644 --- a/c/ext.cpp +++ b/c/ext.cpp @@ -12,7 +12,7 @@ bool OpenOnline(const CfgA& cfg, int iEp) INT_PTR r = reinterpret_cast( ShellExecuteW(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL)); if (r <= 32) - throw Win32Error(); + throw Err(WINDOWS, L"Address "s + url + L" could not be opened: %s"); return true; } @@ -23,7 +23,7 @@ bool OpenWiki(const DlvDataA& d) INT_PTR r = reinterpret_cast( ShellExecuteW(nullptr, L"open", url, nullptr, nullptr, SW_SHOWNORMAL)); if (r <= 32) - throw Win32Error(); + throw Err(WINDOWS, L"Address "s + url + L" could not be opened: %s"); return true; } @@ -84,7 +84,7 @@ static bool FindMatchingFile(wchar_t (&file)[MAX_PATH], const wchar_t* const roo WIN32_FIND_DATA fdata; Unique h = FindFirstFileW(pat, &fdata); if (h.Bad(INVALID_HANDLE_VALUE)) - throw Win32Error(); + throw Err(WINDOWS, L"Directory "s + root + L" could not be traversed: %s"); do if (fdata.cFileName[0] == L'.') @@ -102,7 +102,7 @@ static bool FindMatchingFile(wchar_t (&file)[MAX_PATH], const wchar_t* const roo while (FindNextFileW(h.v, &fdata)); if (GetLastError() != ERROR_NO_MORE_FILES) - throw Win32Error(); + throw Err(WINDOWS, L"Next file in "s + root + L" could not be accessed: %s"); return false; } @@ -114,7 +114,7 @@ bool OpenLocally(CfgA& cfg, const ElvDataA& e) INT_PTR r = reinterpret_cast( ShellExecuteW(nullptr, L"open", file, nullptr, nullptr, SW_SHOWNORMAL)); if (r <= 32) - throw Win32Error(); + throw Err(WINDOWS, L"File "s + file + L" could not be opened: %s"); return true; } else return false; -- cgit v1.2.3