MCPcopy
hub / github.com/elastic/go-elasticsearch / printErrorResponse

Function printErrorResponse

_examples/encoding/easyjson.go:171–183  ·  view source on GitHub ↗

printErrorResponse decodes the response from Elasticsearch and prints it formatted to STDOUT.

(res *esapi.Response)

Source from the content-addressed store, hash-verified

169// printErrorResponse decodes the response from Elasticsearch
170// and prints it formatted to STDOUT.
171func printErrorResponse(res *esapi.Response) {
172 bold.Printf("[%s] ", res.Status())
173
174 var e model.ErrorResponse
175 if err := easyjson.UnmarshalFromReader(res.Body, &e); err != nil {
176 red.Println("Error decoding response:", err)
177 return
178 }
179
180 boldRed.Print(e.Info.RootCause[0].Type)
181 faint.Print(" > ")
182 fmt.Println(e.Info.RootCause[0].Reason)
183}

Callers 1

mainFunction · 0.85

Calls 3

PrintfMethod · 0.80
UnmarshalFromReaderMethod · 0.65
StatusMethod · 0.45

Tested by

no test coverage detected