upgrade github.com/prometheus/common to v0.28.0

This commit is contained in:
paco
2021-07-07 16:22:05 +08:00
parent abd8acc259
commit 18d583653c
91 changed files with 63507 additions and 17064 deletions

View File

@@ -69,6 +69,8 @@ type Error struct {
// Message is the server response message and is only populated when
// explicitly referenced by the JSON server response.
Message string `json:"message"`
// Details provide more context to an error.
Details []interface{} `json:"details"`
// Body is the raw response returned by the server.
// It is often but not always JSON, depending on how the request fails.
Body string
@@ -95,6 +97,16 @@ func (e *Error) Error() string {
if e.Message != "" {
fmt.Fprintf(&buf, "%s", e.Message)
}
if len(e.Details) > 0 {
var detailBuf bytes.Buffer
enc := json.NewEncoder(&detailBuf)
enc.SetIndent("", " ")
if err := enc.Encode(e.Details); err == nil {
fmt.Fprint(&buf, "\nDetails:")
fmt.Fprintf(&buf, "\n%s", detailBuf.String())
}
}
if len(e.Errors) == 0 {
return strings.TrimSpace(buf.String())
}