Print type information when unknown watch error

Got

```
E0628 00:23:07.106285       1 watch.go:274] unable to encode watch object: expected pointer, but got invalid kind
```

on a production system and had no way to debug what type was being sent.
This commit is contained in:
Clayton Coleman 2018-06-27 20:34:48 -04:00
parent 93055c7730
commit 307849baef
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -209,7 +209,7 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
s.Fixup(obj)
if err := s.EmbeddedEncoder.Encode(obj, buf); err != nil {
// unexpected error
utilruntime.HandleError(fmt.Errorf("unable to encode watch object: %v", err))
utilruntime.HandleError(fmt.Errorf("unable to encode watch object %T: %v", obj, err))
return
}
@ -230,7 +230,7 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
return
}
if err := e.Encode(outEvent); err != nil {
utilruntime.HandleError(fmt.Errorf("unable to encode watch object: %v (%#v)", err, e))
utilruntime.HandleError(fmt.Errorf("unable to encode watch object %T: %v (%#v)", outEvent, err, e))
// client disconnect.
return
}
@ -276,7 +276,7 @@ func (s *WatchServer) HandleWS(ws *websocket.Conn) {
s.Fixup(obj)
if err := s.EmbeddedEncoder.Encode(obj, buf); err != nil {
// unexpected error
utilruntime.HandleError(fmt.Errorf("unable to encode watch object: %v", err))
utilruntime.HandleError(fmt.Errorf("unable to encode watch object %T: %v", obj, err))
return
}