Skip to content

Commit 682eccc

Browse files
committed
fix(commit_commands): handle missing API token error gracefully
This commit introduces an error handling mechanism in the commit_code function of commit_commands.py. It adds a check to ensure that if neither an LLM model nor an API token is provided, an error message is printed using the print_error utility. This change improves user experience by providing clear feedback when required parameters are missing, thus preventing potential confusion during the commit process. The addition of this check enhances the robustness of the code by ensuring that users are informed of the necessary prerequisites for successful execution.
1 parent 546aac1 commit 682eccc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

penify_hook/commands/commit_commands.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33

4+
from penify_hook.ui_utils import print_error
45
from penify_hook.utils import recursive_search_git_folder
56
from ..commit_analyzer import CommitDocGenHook
67
from ..api_client import APIClient
@@ -38,6 +39,9 @@ def commit_code(api_url, token, message, open_terminal,
3839
except Exception as e:
3940
print(f"Error initializing LLM client: {e}")
4041
print("Falling back to API for commit summary generation")
42+
else:
43+
if not token:
44+
print_error("No LLM model or API token provided. Please provide an LLM model or API token.")
4145

4246
# Initialize JIRA client if parameters are provided and JiraClient is available
4347
jira_client = None

0 commit comments

Comments
 (0)