You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
542 B
23 lines
542 B
package es
|
|
|
|
import (
|
|
"encoding/json"
|
|
"gitea.drugeyes.vip/pharnexbase/utils/glog/v1"
|
|
"github.com/elastic/go-elasticsearch/v7/esapi"
|
|
)
|
|
|
|
func IsError(res *esapi.Response) bool {
|
|
if res.IsError() {
|
|
var e map[string]interface{}
|
|
if err := json.NewDecoder(res.Body).Decode(&e); err != nil {
|
|
glog.Glog.Error("Error parsing the response body:", err)
|
|
}
|
|
glog.Glog.Errorf("[%s] %s: %s",
|
|
res.Status(),
|
|
e["error"].(map[string]interface{})["type"],
|
|
e["error"].(map[string]interface{})["reason"],
|
|
)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|