From e7cbef777f360d9dede130faba1632437fdd3301 Mon Sep 17 00:00:00 2001 From: Drazzilb <65743746+Drazzilb08@users.noreply.github.com> Date: Sat, 17 Feb 2024 21:51:35 -0800 Subject: [PATCH] add: Error handling --- util/config.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/config.py b/util/config.py index d9d87e7..c1f4c17 100755 --- a/util/config.py +++ b/util/config.py @@ -53,8 +53,15 @@ def load_config(self): """ # Open the YAML config file and load its contents try: - with open(self.config_path, "r") as file: - config = yaml.safe_load(file) + try: + with open(self.config_path, "r") as file: + config = yaml.safe_load(file) + except FileNotFoundError: + logger.error(f"Config file not found at {self.config_path}") + return + except yaml.parser.ParserError as e: + logger.error(f"Error parsing config file: {e}") + return except FileNotFoundError: logger.error(f"Config file not found at {self.config_path}") return