feat: modify error handling to return a list of errors to display to the user at the end of analysis without blocking it if an error is detected (e.g., version of an object is not available on user's cluster)

Signed-off-by: Matthis <matthish29@gmail.com>
This commit is contained in:
Matthis
2023-04-20 11:10:29 +02:00
parent df2ed4185b
commit fa087ff559
3 changed files with 23 additions and 17 deletions

View File

@@ -55,12 +55,14 @@ func (s *Config) analyzeHandler(w http.ResponseWriter, r *http.Request) {
return
}
err = config.RunAnalysis()
if err != nil {
color.Red("Error: %v", err)
analysisErrors := config.RunAnalysis()
if analysisErrors != nil {
var errorMessage string
for _, err := range analysisErrors {
errorMessage += err.Error() + "\n"
}
http.Error(w, errorMessage, http.StatusInternalServerError)
health.Failure++
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if explain {