Better error logging

This commit is contained in:
Armon Dadgar 2013-12-24 12:22:42 -08:00
parent ead9c42abc
commit 37aa0ae7a5
2 changed files with 4 additions and 3 deletions

View File

@ -77,7 +77,7 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
// Check for an error
HAS_ERR:
if err != nil {
s.logger.Printf("[ERR] Request %v, error: %v", req, err)
s.logger.Printf("[ERR] Request %v, error: %v", req.URL, err)
resp.WriteHeader(500)
resp.Write([]byte(err.Error()))
return

View File

@ -1,6 +1,7 @@
package consul
import (
"fmt"
"github.com/ugorji/go/codec"
"net"
"net/rpc"
@ -161,7 +162,7 @@ func (p *ConnPool) RPC(addr net.Addr, method string, args interface{}, reply int
// Try to get a conn first
conn, err := p.Acquire(addr)
if err != nil {
return err
return fmt.Errorf("failed to get conn: %v", err)
}
// Make the RPC call
@ -179,7 +180,7 @@ func (p *ConnPool) RPC(addr net.Addr, method string, args interface{}, reply int
} else {
conn.Close()
}
return err
return fmt.Errorf("rpc error: %v", err)
}
// Reap is used to close conns open over maxTime