Browse Source

Added try catch to check update compatible

Krzysztof Krysiński 1 month ago
parent
commit
4d2dae65d4
1 changed files with 25 additions and 3 deletions
  1. 25 3
      src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

+ 25 - 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,30 @@ 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 (SocketException ex)
+        {
+            UpdateState = UpdateState.UnableToCheck;
+            return;
+        }
+        catch (IOException ex)
+        {
+            UpdateState = UpdateState.UnableToCheck;
+            return;
+        }
+        catch (Exception ex)
+        {
+            UpdateState = UpdateState.UnableToCheck;
+            CrashHelper.SendExceptionInfoAsync(ex);
+            return;
+        }
+
 
         if (!updateExeDoesNotExists || !updateFileDoesNotExists)
         {