Add debugging for issue #149

This commit is contained in:
Robert McRackan 2021-11-05 13:42:47 -04:00
parent 6ff2859c39
commit 283a46e1e2
2 changed files with 18 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>6.4.1.1</Version>
<Version>6.4.2.1</Version>
</PropertyGroup>
<ItemGroup>

View File

@ -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<JObject>(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;
}
}