diff --git a/pkg/ai/openai.go b/pkg/ai/openai.go index 49bf39a509..1da3841ffb 100644 --- a/pkg/ai/openai.go +++ b/pkg/ai/openai.go @@ -77,7 +77,6 @@ func (a *OpenAIClient) Parse(ctx context.Context, prompt []string, nocache bool) response, err := a.GetCompletion(ctx, inputKey) if err != nil { - color.Red("error getting completion: %v", err) return "", err } diff --git a/pkg/analysis/analysis.go b/pkg/analysis/analysis.go index f04ba2d1cb..96e2ea952b 100644 --- a/pkg/analysis/analysis.go +++ b/pkg/analysis/analysis.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "os" "strings" "github.com/fatih/color" @@ -144,13 +143,14 @@ func (a *Analysis) GetAIResults(output string) error { for index, analysis := range a.Results { parsedText, err := a.AIClient.Parse(a.Context, analysis.Error, a.NoCache) if err != nil { + bar.Exit() + // Check for exhaustion if strings.Contains(err.Error(), "status code: 429") { - color.Red("Exhausted API quota. Please try again later") - os.Exit(1) + return fmt.Errorf("exhausted API quota for AI provider %s: %v", a.AIClient.GetName(), err) + } else { + return fmt.Errorf("failed while calling AI provider %s: %v", a.AIClient.GetName(), err) } - color.Red("Error: %v", err) - continue } analysis.Details = parsedText if output != "json" {