Skip to content

Commit

Permalink
Fixed an issue causing a crash when DriverStore couldn't be deserialized
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Nov 30, 2024
1 parent 226a1ae commit 528c697
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions HandheldCompanion/Helpers/DriverStore.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -37,8 +40,17 @@ private static Dictionary<string, string> DeserializeDriverStore()
if (!File.Exists(DriversPath))
return [];

string json = File.ReadAllText(DriversPath);
return JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
try
{
string json = File.ReadAllText(DriversPath);
return JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
}
catch (Exception ex)
{
LogManager.LogError("Could not retrieve drivers store {0}", ex.Message);
}

return [];
}

public static string GetDriverFromDriverStore(string path)
Expand Down

0 comments on commit 528c697

Please sign in to comment.