Skip to content

Commit 846b227

Browse files
committed
client: deprecate ErrorConnectionFailed helper
This function was only used internally, and will be removed in the next release. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent e93ff74 commit 846b227

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

client/errors.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package client // import "github.com/docker/docker/client"
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67

78
"github.com/docker/docker/api/types/versions"
89
"github.com/docker/docker/errdefs"
9-
"github.com/pkg/errors"
1010
)
1111

1212
// errConnectionFailed implements an error returned when connection failed.
@@ -29,10 +29,18 @@ func IsErrConnectionFailed(err error) bool {
2929
}
3030

3131
// ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed.
32+
//
33+
// Deprecated: this function was only used internally, and will be removed in the next release.
3234
func ErrorConnectionFailed(host string) error {
35+
return connectionFailed(host)
36+
}
37+
38+
// connectionFailed returns an error with host in the error message when connection
39+
// to docker daemon failed.
40+
func connectionFailed(host string) error {
3341
var err error
3442
if host == "" {
35-
err = fmt.Errorf("Cannot connect to the Docker daemon. Is the docker daemon running on this host?")
43+
err = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?")
3644
} else {
3745
err = fmt.Errorf("Cannot connect to the Docker daemon at %s. Is the docker daemon running?", host)
3846
}

client/request.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,10 @@ func (cli *Client) doRequest(req *http.Request) (serverResponse, error) {
168168
if errors.As(err, &nErr) {
169169
// FIXME(thaJeztah): any net.Error should be considered a connection error (but we should include the original error)?
170170
if nErr.Timeout() {
171-
return serverResp, ErrorConnectionFailed(cli.host)
171+
return serverResp, connectionFailed(cli.host)
172172
}
173173
if strings.Contains(nErr.Error(), "connection refused") || strings.Contains(nErr.Error(), "dial unix") {
174-
return serverResp, ErrorConnectionFailed(cli.host)
174+
return serverResp, connectionFailed(cli.host)
175175
}
176176
}
177177

0 commit comments

Comments
 (0)