diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2024-03-09 20:02:24 +0100 |
|---|---|---|
| committer | Martin Bielik <mx.bielik@gmail.com> | 2024-03-09 20:07:26 +0100 |
| commit | 188d07f5efa8a4cde3407e71ca2013c10c051bba (patch) | |
| tree | adc7299b3be06c10527cd8e1da643f2acab8bc42 /py | |
| parent | 155d0c8eda5e5effdd7a234da46db18fbe32e17a (diff) | |
| download | vim-ai-188d07f5efa8a4cde3407e71ca2013c10c051bba.tar.gz | |
simple error handling
Diffstat (limited to 'py')
| -rw-r--r-- | py/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/py/utils.py b/py/utils.py index 6600fc3..9ef8b72 100644 --- a/py/utils.py +++ b/py/utils.py @@ -265,10 +265,14 @@ def clear_echo_message(): def load_role_config(role): 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) + if not role in roles: - raise KnownError(f"Role {role} not found") # TODO handle errors + raise Exception(f"Role `{role}` not found") options = roles[f"{role}.options"] if f"{role}.options" in roles else {} options_complete =roles[f"{role}.options-complete"] if f"{role}.options-complete" in roles else {} |