fix: exit progressbar on error (#99)

Signed-off-by: Thomas Stadler <thomas@thomasst.xyz>
This commit is contained in:
Thomas Stadler
2023-04-10 20:01:55 +02:00
parent ba01bd4b6e
commit ab55f157ef
2 changed files with 5 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"github.com/fatih/color"
@@ -143,13 +142,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" {