Skip to content

Commit

Permalink
fix: exit progressbar on error (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Stadler <thomas@thomasst.xyz>
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
thomasstxyz authored and AlexsJones committed Apr 11, 2023
1 parent b45ff1a commit fe261b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/ai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/analysis/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strings"

"github.com/fatih/color"
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit fe261b3

Please sign in to comment.