Browse Source

Return underlying network errors in Dial methods; improve doc.

Gary Burd 12 years ago
parent
commit
61ad8688f1
2 changed files with 6 additions and 4 deletions
  1. 2 2
      redis/conn.go
  2. 4 2
      redis/redis.go

+ 2 - 2
redis/conn.go

@@ -55,7 +55,7 @@ type conn struct {
 func Dial(network, address string) (Conn, error) {
 func Dial(network, address string) (Conn, error) {
 	c, err := net.Dial(network, address)
 	c, err := net.Dial(network, address)
 	if err != nil {
 	if err != nil {
-		return nil, errors.New("Could not connect to Redis server: " + err.Error())
+		return nil, err
 	}
 	}
 	return NewConn(c, 0, 0), nil
 	return NewConn(c, 0, 0), nil
 }
 }
@@ -71,7 +71,7 @@ func DialTimeout(network, address string, connectTimeout, readTimeout, writeTime
 		c, err = net.Dial(network, address)
 		c, err = net.Dial(network, address)
 	}
 	}
 	if err != nil {
 	if err != nil {
-		return nil, errors.New("Could not connect to Redis server: " + err.Error())
+		return nil, err
 	}
 	}
 	return NewConn(c, readTimeout, writeTimeout), nil
 	return NewConn(c, readTimeout, writeTimeout), nil
 }
 }

+ 4 - 2
redis/redis.go

@@ -24,8 +24,10 @@ type Conn interface {
 	// Close closes the connection.
 	// Close closes the connection.
 	Close() error
 	Close() error
 
 
-	// Err returns a non-nil value if the connection has failed because of a
-	// protocol error or an error from the underlying network connection.
+	// Err returns a non-nil value if the connection is broken. The returned
+	// value is either the first non-nil value returned from the underlying
+	// network connection or a protocol parsing error. Applications should
+	// close broken connections.
 	Err() error
 	Err() error
 
 
 	// Do sends a command to the server and returns the received reply.
 	// Do sends a command to the server and returns the received reply.