fix: add error handling when saving debug settings

This commit is contained in:
Nick Genovese
2025-09-22 10:17:16 -04:00
parent 383af5dc53
commit 75808ababc

View File

@@ -957,15 +957,24 @@ public static class Debug
//if (!Directory.Exists(dir)) //if (!Directory.Exists(dir))
// Directory.Create(dir); // Directory.Create(dir);
var fileName = GetMemoryFileName(); try
LogMessage(LogEventLevel.Information, "Loading debug settings file from {fileName}", fileName);
using (var sw = new StreamWriter(fileName))
{ {
var json = JsonConvert.SerializeObject(_contexts); var fileName = GetMemoryFileName();
sw.Write(json);
sw.Flush(); LogMessage(LogEventLevel.Information, "Loading debug settings file from {fileName}", fileName);
using (var sw = new StreamWriter(fileName))
{
var json = JsonConvert.SerializeObject(_contexts);
sw.Write(json);
sw.Flush();
}
}
catch (Exception ex)
{
ErrorLog.Error("Exception saving debug settings: {message}", ex);
CrestronConsole.PrintLine("Exception saving debug settings: {message}", ex.Message);
return;
} }
} }