Skip to content

Commit d048215

Browse files
committed
fix #3 : improve API key error messages
Add specific instructions for setting environment variables when API keys are missing
1 parent cfa79db commit d048215

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

cmd/cli/createMsg.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func CreateCommitMsg () {
2222
// Validate COMMIT_LLM and required API keys
2323
useLLM,err := store.DefaultLLMKey()
2424
if err != nil {
25-
pterm.Error.Printf("Error: %v\n", err)
25+
pterm.Error.Printf("No LLM configured. Run: commit llm setup\n")
2626
os.Exit(1)
2727
}
2828

@@ -64,7 +64,7 @@ func CreateCommitMsg () {
6464
pterm.DefaultHeader.WithFullWidth().
6565
WithBackgroundStyle(pterm.NewStyle(pterm.BgDarkGray)).
6666
WithTextStyle(pterm.NewStyle(pterm.FgLightWhite)).
67-
Println("🚀 Commit Message Generator")
67+
Println("Commit Message Generator")
6868

6969
pterm.Println()
7070

@@ -93,7 +93,7 @@ func CreateCommitMsg () {
9393
// Show generating spinner
9494
spinnerGenerating, err := pterm.DefaultSpinner.
9595
WithSequence("⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏").
96-
Start("🤖 Generating commit message...")
96+
Start("Generating commit message...")
9797
if err != nil {
9898
pterm.Error.Printf("Failed to start spinner: %v\n", err)
9999
os.Exit(1)
@@ -119,7 +119,18 @@ func CreateCommitMsg () {
119119

120120
if err != nil {
121121
spinnerGenerating.Fail("Failed to generate commit message")
122-
pterm.Error.Printf("Error: %v\n", err)
122+
switch commitLLM {
123+
case "Gemini":
124+
pterm.Error.Printf("Gemini API error. Check your GEMINI_API_KEY environment variable or run: commit llm setup\n")
125+
case "OpenAI":
126+
pterm.Error.Printf("OpenAI API error. Check your OPENAI_API_KEY environment variable or run: commit llm setup\n")
127+
case "Claude":
128+
pterm.Error.Printf("Claude API error. Check your CLAUDE_API_KEY environment variable or run: commit llm setup\n")
129+
case "Grok":
130+
pterm.Error.Printf("Grok API error. Check your GROK_API_KEY environment variable or run: commit llm setup\n")
131+
default:
132+
pterm.Error.Printf("LLM API error: %v\n", err)
133+
}
123134
os.Exit(1)
124135
}
125136

0 commit comments

Comments
 (0)