From 7e814b37c3f93db750ef0bc51878dfb7b0fcf408 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Sat, 26 Aug 2023 16:31:36 +0200 Subject: [PATCH] catch errors on update/install --- ModpackUpdater/Form1.vb | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/ModpackUpdater/Form1.vb b/ModpackUpdater/Form1.vb index 34f46e0..9148c65 100644 --- a/ModpackUpdater/Form1.vb +++ b/ModpackUpdater/Form1.vb @@ -84,7 +84,13 @@ Public Class Form1 'Check only if not pressed "install", not really needed otherwise. If lastUpdateCheckResult Is Nothing OrElse Not doInstall Then SetStatus(LangRes.StatusText_CheckingForUpdates, MySymbols.icons8_update_16px) - lastUpdateCheckResult = Await updater.CheckForUpdates(Not AppConfig.Instance.AllowRemoveLocalFiles) + + Try + lastUpdateCheckResult = Await updater.CheckForUpdates(Not AppConfig.Instance.AllowRemoveLocalFiles) + Catch + SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px) + Finally + End Try End If If lastUpdateCheckResult Is Nothing OrElse lastUpdateCheckResult.HasError Then @@ -94,14 +100,18 @@ Public Class Form1 SetStatus(LangRes.StatusText_Installing, MySymbols.icons8_software_installer_16px) currentUpdating = True - If Await updater.InstallUpdates(lastUpdateCheckResult) Then - lastUpdateCheckResult = Nothing 'Reset last update check, a new one would be needed now. - SetStatus(LangRes.StatusTest_EverythingOk, MySymbols.icons8_checkmark_16px) - Else + Try + If Await updater.InstallUpdates(lastUpdateCheckResult) Then + lastUpdateCheckResult = Nothing 'Reset last update check, a new one would be needed now. + SetStatus(LangRes.StatusTest_EverythingOk, MySymbols.icons8_checkmark_16px) + Else + SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px) + End If + Catch SetStatus(LangRes.StatusText_ErrorWhileUpdateCheckOrUpdate, MySymbols.icons8_delete_16px) - End If - - currentUpdating = False + Finally + currentUpdating = False + End Try Else SetStatus(LangRes.StatusText_UpdateAvailable, MySymbols.icons8_software_installer_16px) End If