Browse Source

Merge pull request #1187 from PixiEditor/fix/try-catch-update

Added try catch to check update compatible
Krzysztof Krysiński 1 week ago
parent
commit
4e0e1fec98
1 changed files with 19 additions and 3 deletions
  1. 19 3
      src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

+ 19 - 3
src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

@@ -3,6 +3,7 @@ using System.ComponentModel;
 using System.Diagnostics;
 using System.IO;
 using System.Linq;
+using System.Net.Sockets;
 using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
@@ -212,9 +213,24 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
 
     public async Task Download()
     {
-        bool updateCompatible = await UpdateChecker.IsUpdateCompatible();
-        bool updateFileDoesNotExists = !AutoUpdateFileExists();
-        bool updateExeDoesNotExists = !UpdateInstallerFileExists();
+        bool updateCompatible, updateFileDoesNotExists, updateExeDoesNotExists;
+        try
+        {
+            updateCompatible = await UpdateChecker.IsUpdateCompatible();
+            updateFileDoesNotExists = !AutoUpdateFileExists();
+            updateExeDoesNotExists = !UpdateInstallerFileExists();
+        }
+        catch (Exception ex)
+        {
+            UpdateState = UpdateState.UnableToCheck;
+            if (ex is not IOException && ex is not SocketException)
+            {
+                CrashHelper.SendExceptionInfo(ex);
+            }
+
+            return;
+        }
+
 
         if (!updateExeDoesNotExists || !updateFileDoesNotExists)
         {