浏览代码

Return underlying network errors in Dial methods; improve doc.

Gary Burd 12 年之前
父节点
当前提交
61ad8688f1
共有 2 个文件被更改,包括 6 次插入4 次删除
  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) {
 	c, err := net.Dial(network, address)
 	if err != nil {
-		return nil, errors.New("Could not connect to Redis server: " + err.Error())
+		return nil, err
 	}
 	return NewConn(c, 0, 0), nil
 }
@@ -71,7 +71,7 @@ func DialTimeout(network, address string, connectTimeout, readTimeout, writeTime
 		c, err = net.Dial(network, address)
 	}
 	if err != nil {
-		return nil, errors.New("Could not connect to Redis server: " + err.Error())
+		return nil, err
 	}
 	return NewConn(c, readTimeout, writeTimeout), nil
 }

+ 4 - 2
redis/redis.go

@@ -24,8 +24,10 @@ type Conn interface {
 	// Close closes the connection.
 	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
 
 	// Do sends a command to the server and returns the received reply.