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; } }