fix: return early if config devices are null, with an appropriate log message

This commit is contained in:
Andrew Welker 2026-04-24 10:19:18 -05:00
parent dc656bddf1
commit 89a1b662b0

View file

@ -1,7 +1,10 @@
using System;
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
@ -12,14 +15,11 @@ using PepperDash.Core.Adapters;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Routing;
using System.Threading;
using Timeout = Crestron.SimplSharp.Timeout;
using Serilog.Events;
using System.Threading.Tasks;
using PepperDash.Essentials.Core.Web;
using System.Collections.Generic;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Core.Web;
using Serilog.Events;
using Timeout = Crestron.SimplSharp.Timeout;
namespace PepperDash.Essentials;
@ -506,9 +506,13 @@ public class ControlSystem : CrestronControlSystem, ILoadConfig, IInitialization
new Core.Monitoring.SystemMonitorController("systemMonitor"));
}
if (ConfigReader.ConfigObject is not null)
if (ConfigReader.ConfigObject is null)
{
Debug.LogMessage(LogEventLevel.Warning, "LoadDevices: ConfigObject is null. Cannot load devices.");
return;
}
Debug.LogInformation("Loading devices from config.");
foreach (var devConf in ConfigReader.ConfigObject.Devices)
{
@ -549,10 +553,11 @@ public class ControlSystem : CrestronControlSystem, ILoadConfig, IInitialization
Debug.LogMessage(e, "ERROR: Creating device {deviceKey:l}. Skipping device.", args: new[] { devConf.Key });
}
}
}
Debug.LogMessage(LogEventLevel.Information, "All Devices Loaded.");
return;
}