mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-05-01 21:03:30 +00:00
fix: exit progressbar on error (#99)
Signed-off-by: Thomas Stadler <thomas@thomasst.xyz>
This commit is contained in:
parent
ba01bd4b6e
commit
ab55f157ef
@ -77,7 +77,6 @@ func (a *OpenAIClient) Parse(ctx context.Context, prompt []string, nocache bool)
|
|||||||
|
|
||||||
response, err := a.GetCompletion(ctx, inputKey)
|
response, err := a.GetCompletion(ctx, inputKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
color.Red("error getting completion: %v", err)
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
@ -143,13 +142,14 @@ func (a *Analysis) GetAIResults(output string) error {
|
|||||||
for index, analysis := range a.Results {
|
for index, analysis := range a.Results {
|
||||||
parsedText, err := a.AIClient.Parse(a.Context, analysis.Error, a.NoCache)
|
parsedText, err := a.AIClient.Parse(a.Context, analysis.Error, a.NoCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
bar.Exit()
|
||||||
|
|
||||||
// Check for exhaustion
|
// Check for exhaustion
|
||||||
if strings.Contains(err.Error(), "status code: 429") {
|
if strings.Contains(err.Error(), "status code: 429") {
|
||||||
color.Red("Exhausted API quota. Please try again later")
|
return fmt.Errorf("exhausted API quota for AI provider %s: %v", a.AIClient.GetName(), err)
|
||||||
os.Exit(1)
|
} else {
|
||||||
|
return fmt.Errorf("failed while calling AI provider %s: %v", a.AIClient.GetName(), err)
|
||||||
}
|
}
|
||||||
color.Red("Error: %v", err)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
analysis.Details = parsedText
|
analysis.Details = parsedText
|
||||||
if output != "json" {
|
if output != "json" {
|
||||||
|
Loading…
Reference in New Issue
Block a user