summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonfekt <Konfekt@users.noreply.github.com>2024-03-10 21:28:54 +0100
committerKonfekt <Konfekt@users.noreply.github.com>2024-03-10 21:42:11 +0100
commitaf52f039513b11e9820ce0bf1e46596a454ebd44 (patch)
treed5ce61eec5f81d6136a09b97f7cd6ec88aa235b6
parent5709ab1ce75f05e9b57bf052f3ad92aa74f61c16 (diff)
downloadvim-ai-af52f039513b11e9820ce0bf1e46596a454ebd44.tar.gz
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}") -
-rw-r--r--py/roles.py3
1 files changed, 3 insertions, 0 deletions
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)