From 0dab9cc427507228698ad6b010af3c8c9eefa3a3 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Wed, 8 Oct 2025 17:33:56 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(config):=20improve=20rule=20?= =?UTF-8?q?removal=20and=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix the logic of `remove_rule_by_label` to check label existence correctly - change the error returned when label not found to include the label - add log information when removing rules by id or label --- src/config.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index d3de420..0f76fde 100644 --- a/src/config.rs +++ b/src/config.rs @@ -109,7 +109,7 @@ impl Config { /// Remove a rule by the ID specified pub fn remove_rule_by_id(&mut self, id: usize) -> crate::Result<()> { self.rules.remove(&id.to_string()); - + log::info!("Rule `{id}` has been removed."); Ok(()) } @@ -117,8 +117,8 @@ impl Config { pub fn remove_rule_by_label(&mut self, label: &str) -> crate::Result<()> { let labels = self.labels(); - if labels.contains(&label.to_string()) { - return Err(Error::LabelNotFoundInRules); + if !labels.contains(&label.to_string()) { + return Err(Error::LabelNotFoundInRules(label.to_string())); } let rule_id = self.find_label(label); @@ -128,6 +128,7 @@ impl Config { self.rules.remove(&rule_id.to_string()); + log::info!("Rule containing the label `{label}` has been removed."); Ok(()) }