From 0e787bbca8ef202523c5f531ae9dc56e75801325 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Fri, 28 May 2021 21:09:09 -0400 Subject: [PATCH] better deserialization --- src/BSLManager/Tools/SettingsManager.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/BSLManager/Tools/SettingsManager.cs b/src/BSLManager/Tools/SettingsManager.cs index db98d71..5ff6314 100644 --- a/src/BSLManager/Tools/SettingsManager.cs +++ b/src/BSLManager/Tools/SettingsManager.cs @@ -90,11 +90,18 @@ namespace BSLManager.Tools private LocalSettingsData GetLocalSettingsFile() { - if (!File.Exists(LocalFileName)) return null; + try + { + if (!File.Exists(LocalFileName)) return null; - var jsonContent = File.ReadAllText(LocalFileName); - var content = JsonConvert.DeserializeObject(jsonContent); - return content; + var jsonContent = File.ReadAllText(LocalFileName); + var content = JsonConvert.DeserializeObject(jsonContent); + return content; + } + catch (Exception) + { + return null; + } } private void SaveLocalSettings(LocalSettingsData data)