From f735104d37ecf4af643a08edafb8295af2cc4325 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radoslav=20Bod=C3=B3?= <bodik@cesnet.cz>
Date: Tue, 16 Apr 2024 11:38:40 +0200
Subject: [PATCH] rwm: more on config file error handling

---
 rwm.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/rwm.py b/rwm.py
index b356219..d90dced 100755
--- a/rwm.py
+++ b/rwm.py
@@ -709,7 +709,7 @@ def parse_arguments(argv):
     return parser.parse_args(argv)
 
 
-def load_config(path):
+def load_config(path) -> dict:
     """load config dict from file"""
 
     config = {}
@@ -718,9 +718,10 @@ def load_config(path):
         config_perms = config_path.stat().st_mode & 0o777
         if config_perms != 0o600:
             logger.warning(f"config file permissions ({config_perms:o}) are too-open")
-        config = yaml.safe_load(config_path.read_text(encoding='utf-8'))
-    except (OSError, ValueError) as exc:
+        config = dict(yaml.safe_load(config_path.read_text(encoding='utf-8')))
+    except (OSError, TypeError, ValueError) as exc:
         logger.error(f"cannot load config file, {exc}")
+
     logger.debug("config, %s", config)
     return config
 
-- 
GitLab