mirror of
				https://github.com/k8sgpt-ai/k8sgpt.git
				synced 2025-10-30 21:30:30 +00:00 
			
		
		
		
	fix: exit progressbar on error (#99)
Signed-off-by: Thomas Stadler <thomas@thomasst.xyz>
This commit is contained in:
		| @@ -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 | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -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" { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user