Skip to content

🔧 Add error handling improvements to terminal-ai #26

@josharsh

Description

@josharsh

🎯 Goal

Improve error handling in terminal-ai/terminal.py for better UX.

📋 Description

Currently, the tool doesn't handle some edge cases gracefully. Let's make it bulletproof!

🐛 Issues to Fix

1. API Key Missing

Currently crashes. Should show friendly message:

⚠️  ANTHROPIC_API_KEY not found!

Set it with:
  export ANTHROPIC_API_KEY="your-key"

Get your key: https://console.anthropic.com/

2. Network Errors

Add retry logic and timeout handling:

try:
    response = client.messages.create(...)
except APIError as e:
    print("🔴 API Error. Retrying...")
    # retry logic

3. Empty Input

Handle empty commands gracefully:

💭 What do you want to do?

⚠️  Please describe what you'd like to do!

4. Command Timeout

Add timeout for long-running commands

📁 File to Update

terminal-ai/terminal.py (around lines 30-80)

✅ Acceptance Criteria

  • Friendly error messages (no stack traces for users)
  • API key validation on startup
  • Network error retry (3 attempts)
  • Empty input validation
  • Timeout handling for commands
  • Updated README with troubleshooting section

🎓 Learning Outcomes

  • Error handling patterns
  • User experience design
  • Defensive programming
  • API integration

Estimated time: 2-3 hours
Impact: Better user experience for everyone!

💡 Reference

See commit-ai/commit.py for good error handling examples!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood-first-issueGood for newcomershacktoberfestHacktoberfest participation welcomehelp-wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions