mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: doRequest: use errors.As for error-detection
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -154,15 +154,18 @@ func (cli *Client) doRequest(req *http.Request) (serverResponse, error) {
|
||||
return serverResp, err
|
||||
}
|
||||
|
||||
if uErr, ok := err.(*url.Error); ok {
|
||||
if nErr, ok := uErr.Err.(*net.OpError); ok {
|
||||
var uErr *url.Error
|
||||
if errors.As(err, &uErr) {
|
||||
var nErr *net.OpError
|
||||
if errors.As(uErr.Err, &nErr) {
|
||||
if os.IsPermission(nErr.Err) {
|
||||
return serverResp, errConnectionFailed{errors.Wrapf(err, "permission denied while trying to connect to the Docker daemon socket at %v", cli.host)}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if nErr, ok := err.(net.Error); ok {
|
||||
var nErr net.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)
|
||||
|
||||
Reference in New Issue
Block a user