From 528c697ee3c5def6502e66192e20e9339f147c6a Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Sat, 30 Nov 2024 15:01:59 +0100 Subject: [PATCH] Fixed an issue causing a crash when DriverStore couldn't be deserialized --- HandheldCompanion/Helpers/DriverStore.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/HandheldCompanion/Helpers/DriverStore.cs b/HandheldCompanion/Helpers/DriverStore.cs index ec048eabb..eadea5f2f 100644 --- a/HandheldCompanion/Helpers/DriverStore.cs +++ b/HandheldCompanion/Helpers/DriverStore.cs @@ -1,7 +1,10 @@ -using HandheldCompanion.Views; +using HandheldCompanion.Shared; +using HandheldCompanion.Views; using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; +using static PInvoke.Kernel32; namespace HandheldCompanion.Helpers { @@ -37,8 +40,17 @@ private static Dictionary DeserializeDriverStore() if (!File.Exists(DriversPath)) return []; - string json = File.ReadAllText(DriversPath); - return JsonConvert.DeserializeObject>(json); + try + { + string json = File.ReadAllText(DriversPath); + return JsonConvert.DeserializeObject>(json); + } + catch (Exception ex) + { + LogManager.LogError("Could not retrieve drivers store {0}", ex.Message); + } + + return []; } public static string GetDriverFromDriverStore(string path)