From 9b2611be02040b1f4c7e6a02e96b12e94e056b23 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 2 Sep 2022 15:00:00 -0600 Subject: [PATCH] refactor: add error handling for cases where type isn't found --- .../UI/EssentialsTouchpanelController.cs | 5 +++++ .../PepperDashEssentialsBase/UI/TouchpanelBase.cs | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs b/PepperDashEssentials/UI/EssentialsTouchpanelController.cs index 34d5e11a..67f25f42 100644 --- a/PepperDashEssentials/UI/EssentialsTouchpanelController.cs +++ b/PepperDashEssentials/UI/EssentialsTouchpanelController.cs @@ -219,6 +219,11 @@ namespace PepperDash.Essentials var panel = GetPanelForType(dc.Type, comm.IpIdInt, props.ProjectName); + if (panel == null) + { + Debug.Console(0, "Unable to create Touchpanel for type {0}. Touchpanel Controller WILL NOT function correctly", dc.Type); + } + Debug.Console(1, "Factory Attempting to create new EssentialsTouchpanelController"); var panelController = new EssentialsTouchpanelController(dc.Key, dc.Name, panel, props); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs index fbb7cd32..36e0342e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/UI/TouchpanelBase.cs @@ -29,7 +29,14 @@ namespace PepperDash.Essentials.Core.UI /// IP-ID to use for touch panel protected TouchpanelBase(string key, string name, BasicTriListWithSmartObject panel, CrestronTouchpanelPropertiesConfig config) :base(key, name) - { + { + + if (Panel == null) + { + Debug.Console(0, this, "Panel is not valid. Touchpanel class WILL NOT work correctly"); + return; + } + Panel = panel; Panel.SigChange += Panel_SigChange;