1
0
mirror of https://github.com/k8sgpt-ai/k8sgpt.git synced 2025-04-30 04:14:30 +00:00

fix: exit progressbar on error ()

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
No known key found for this signature in database
GPG Key ID: B41E44856376B1F6
2 changed files with 5 additions and 6 deletions

View File

@ -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
}

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" {