printErrorResponse decodes the response from Elasticsearch and prints it formatted to STDOUT.
(res *esapi.Response)
| 169 | // printErrorResponse decodes the response from Elasticsearch |
| 170 | // and prints it formatted to STDOUT. |
| 171 | func 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 | } |
no test coverage detected