From af52f039513b11e9820ce0bf1e46596a454ebd44 Mon Sep 17 00:00:00 2001 From: Konfekt Date: Sun, 10 Mar 2024 21:28:54 +0100 Subject: Ensure role config file exists before loading to prevent errors The problem was that the application tried to load a roles configuration file without checking whether it actually exists, potentially leading to unhandled exceptions if the file is missing. Ensure that the roles configuration file exists before attempting to read from it; raise an exception with a clear message if the file is not found. diff --git a/py/roles.py b/py/roles.py: -if not os.path.exists(roles_config_path): - raise Exception(f"Role config file does not exist: {roles_config_path}") - --- py/roles.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/roles.py b/py/roles.py index 7c7cf13..a8689f2 100644 --- a/py/roles.py +++ b/py/roles.py @@ -3,6 +3,9 @@ import os import configparser roles_config_path = os.path.expanduser(vim.eval("g:vim_ai_roles_config_file")) +if not os.path.exists(roles_config_path): + raise Exception(f"Role config file does not exist: {roles_config_path}") + roles = configparser.ConfigParser() roles.read(roles_config_path) -- cgit v1.2.3