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 // Check for an error
HAS_ERR: HAS_ERR:
if err != nil { 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.WriteHeader(500)
resp.Write([]byte(err.Error())) resp.Write([]byte(err.Error()))
return return

View File

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