From 95bfb81f69b52ba0f60970961779c2f5cf2cbbf2 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Mon, 9 Feb 2026 02:07:02 +0100 Subject: [PATCH] updater: Improve exception handling Logs exceptions and changes QuickWriteFile to throw a catchable exception instead of a DWORD. --- frontend/updater/updater.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/updater/updater.cpp b/frontend/updater/updater.cpp index c15fb3c0a..978a2974f 100644 --- a/frontend/updater/updater.cpp +++ b/frontend/updater/updater.cpp @@ -14,21 +14,22 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "updater.hpp" #include "manifest.hpp" +#include "updater.hpp" #include -#include #include +#include #include +#include #include +#include +#include #include #include -#include #include -#include using namespace std; using namespace updater; @@ -219,11 +220,11 @@ try { WinHandle handle = CreateFile(file, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, nullptr); if (handle == INVALID_HANDLE_VALUE) - throw GetLastError(); + throw LastError(); DWORD written; if (!WriteFile(handle, data, (DWORD)size, &written, nullptr)) - throw GetLastError(); + throw LastError(); return true; @@ -491,7 +492,11 @@ try { return true; +} catch (const exception &e) { + Status(L"Exception: %S", e.what()); + return false; } catch (...) { + Status(L"Unknown exception occurred in RunDownloadWorkers"); return false; } @@ -634,7 +639,11 @@ try { for (auto &result : futures) { result.wait(); } + +} catch (const exception &e) { + Status(L"Exception: %S", e.what()); } catch (...) { + Status(L"Unknown exception occurred in RunHasherWorkers"); } /* ----------------------------------------------------------------------- */ @@ -1075,7 +1084,11 @@ try { return true; +} catch (const exception &e) { + Status(L"Exception: %S", e.what()); + return false; } catch (...) { + Status(L"Unknown exception occurred in RunUpdateWorkers"); return false; }