mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: deprecate ErrorConnectionFailed helper
This function was only used internally, and will be removed in the next release. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -2,11 +2,11 @@ package client // import "github.com/docker/docker/client"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// errConnectionFailed implements an error returned when connection failed.
|
||||
@@ -29,10 +29,18 @@ func IsErrConnectionFailed(err error) bool {
|
||||
}
|
||||
|
||||
// ErrorConnectionFailed returns an error with host in the error message when connection to docker daemon failed.
|
||||
//
|
||||
// Deprecated: this function was only used internally, and will be removed in the next release.
|
||||
func ErrorConnectionFailed(host string) error {
|
||||
return connectionFailed(host)
|
||||
}
|
||||
|
||||
// connectionFailed returns an error with host in the error message when connection
|
||||
// to docker daemon failed.
|
||||
func connectionFailed(host string) error {
|
||||
var err error
|
||||
if host == "" {
|
||||
err = fmt.Errorf("Cannot connect to the Docker daemon. Is the docker daemon running on this host?")
|
||||
err = errors.New("Cannot connect to the Docker daemon. Is the docker daemon running on this host?")
|
||||
} else {
|
||||
err = fmt.Errorf("Cannot connect to the Docker daemon at %s. Is the docker daemon running?", host)
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ func (cli *Client) doRequest(req *http.Request) (serverResponse, error) {
|
||||
if errors.As(err, &nErr) {
|
||||
// FIXME(thaJeztah): any net.Error should be considered a connection error (but we should include the original error)?
|
||||
if nErr.Timeout() {
|
||||
return serverResp, ErrorConnectionFailed(cli.host)
|
||||
return serverResp, connectionFailed(cli.host)
|
||||
}
|
||||
if strings.Contains(nErr.Error(), "connection refused") || strings.Contains(nErr.Error(), "dial unix") {
|
||||
return serverResp, ErrorConnectionFailed(cli.host)
|
||||
return serverResp, connectionFailed(cli.host)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user