From a9fce3237cb2db50cb4b2c73b758f3aedf45a712 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Thu, 18 Mar 2021 12:43:29 -0600 Subject: [PATCH] Added check for key to Clear command If the key was wrong or wasn't in the group, a `KeyNotFoundException` was thrown. Also added acknowledgment of a successful deletion --- .../PepperDashEssentialsBase/Global/Scheduler.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs index e07ef496..928f5557 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Global/Scheduler.cs @@ -36,12 +36,26 @@ namespace PepperDash.Essentials.Core /// static void ClearEventsFromGroup(string groupName) { + if (!EventGroups.ContainsKey(groupName)) + { + Debug.Console(0, + "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", + groupName); + return + } + var group = EventGroups[groupName]; if (group != null) + { group.ClearAllEvents(); + + Debug.Console(0, "[Scheduler]: All events deleted from group '{0}'", groupName); + } else - Debug.Console(0, "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", groupName); + Debug.Console(0, + "[Scheduler]: Unable to delete events from group '{0}'. Group not found in EventGroups dictionary.", + groupName); } static void ListAllEventGroups(string command)