mirror of
https://github.com/coredns/coredns.git
synced 2025-10-30 09:43:17 -04:00
middleware/etcd: Return json parsing errors (#158)
When coredns unmarshals a json value and it fails it will put the error in the returned message iff the query was a debug query (o-o.debug.<REST>).
This commit is contained in:
@@ -36,3 +36,21 @@ func servicesToTxt(debug []msg.Service) []dns.RR {
|
||||
}
|
||||
return rr
|
||||
}
|
||||
|
||||
func errorToTxt(err error) dns.RR {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
msg := err.Error()
|
||||
if len(msg) > 255 {
|
||||
msg = msg[:255]
|
||||
}
|
||||
t := new(dns.TXT)
|
||||
t.Hdr.Class = dns.ClassCHAOS
|
||||
t.Hdr.Ttl = 0
|
||||
t.Hdr.Rrtype = dns.TypeTXT
|
||||
t.Hdr.Name = "."
|
||||
|
||||
t.Txt = []string{msg}
|
||||
return t
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user