From 283a46e1e22a183cbd69c187f85bef7c7ebe0a34 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Fri, 5 Nov 2021 13:42:47 -0400 Subject: [PATCH] Add debugging for issue #149 --- AppScaffolding/AppScaffolding.csproj | 2 +- FileManager/PersistentDictionary.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/AppScaffolding/AppScaffolding.csproj b/AppScaffolding/AppScaffolding.csproj index 67f3972d..a5810f21 100644 --- a/AppScaffolding/AppScaffolding.csproj +++ b/AppScaffolding/AppScaffolding.csproj @@ -3,7 +3,7 @@ net5.0 - 6.4.1.1 + 6.4.2.1 diff --git a/FileManager/PersistentDictionary.cs b/FileManager/PersistentDictionary.cs index 34cd13d3..bbbd46e6 100644 --- a/FileManager/PersistentDictionary.cs +++ b/FileManager/PersistentDictionary.cs @@ -205,8 +205,25 @@ namespace FileManager private JObject readFile() { + if (!File.Exists(Filepath)) + { + var msg = "Unrecoverable error. Settings file cannot be found"; + var ex = new FileNotFoundException(msg, Filepath); + Serilog.Log.Logger.Error(msg, ex); + throw ex; + } + var settingsJsonContents = File.ReadAllText(Filepath); var jObject = JsonConvert.DeserializeObject(settingsJsonContents); + + if (jObject is null) + { + var msg = "Unrecoverable error. Unable to read settings from Settings file"; + var ex = new NullReferenceException(msg); + Serilog.Log.Logger.Error(msg, ex); + throw ex; + } + return jObject; } }