This commit is contained in:
2026-07-07 09:22:18 +02:00
parent f10366dbde
commit 24038e36f7
7 changed files with 12 additions and 25 deletions

View File

@@ -18,6 +18,7 @@ package es
import (
"fmt"
"strings"
"github.com/elastic/go-elasticsearch/v9/typedapi/types"
)
@@ -27,14 +28,14 @@ func esErrorString(err error) string {
switch e := err.(type) {
case *types.ElasticsearchError:
causes := ""
var causes strings.Builder
for _, cause := range e.ErrorCause.RootCause {
causes += fmt.Sprintf("%s\n", *cause.Reason)
causes.WriteString(fmt.Sprintf("%s\n", *cause.Reason))
}
if e.ErrorCause.Reason != nil {
msg = *e.ErrorCause.Reason + ": " + causes
msg = *e.ErrorCause.Reason + ": " + causes.String()
} else {
msg = fmt.Sprintf("http status %d: ", e.Status)
}