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:
Miek Gieben
2016-06-07 20:57:45 +01:00
parent d04abdf422
commit 3110306296
4 changed files with 41 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ package etcd
import (
"encoding/json"
"fmt"
"strings"
"time"
@@ -104,7 +105,7 @@ Nodes:
}
serv := new(msg.Service)
if err := json.Unmarshal([]byte(n.Value), serv); err != nil {
return nil, err
return nil, fmt.Errorf("%s: %s", n.Key, err.Error())
}
b := msg.Service{Host: serv.Host, Port: serv.Port, Priority: serv.Priority, Weight: serv.Weight, Text: serv.Text, Key: n.Key}
if _, ok := bx[b]; ok {