mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client.sendRequest: clean-up logic for error-handling
Only use checkResponseErr if `client.doRequest` did not return an error; any error returned by `client.doRequest` means there was an error connecting, so there's no response to handle (including errors in the response). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -123,14 +123,14 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
|
||||
}
|
||||
|
||||
resp, err := cli.doRequest(req)
|
||||
switch {
|
||||
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
|
||||
return nil, err
|
||||
case err == nil:
|
||||
return resp, checkResponseErr(resp)
|
||||
default:
|
||||
if err != nil {
|
||||
// Failed to connect or context error.
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// Successfully made a request; return the response and handle any
|
||||
// API HTTP response errors.
|
||||
return resp, checkResponseErr(resp)
|
||||
}
|
||||
|
||||
// doRequest sends an HTTP request and returns an HTTP response. It is a
|
||||
|
||||
12
vendor/github.com/moby/moby/client/request.go
generated
vendored
12
vendor/github.com/moby/moby/client/request.go
generated
vendored
@@ -123,14 +123,14 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
|
||||
}
|
||||
|
||||
resp, err := cli.doRequest(req)
|
||||
switch {
|
||||
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
|
||||
return nil, err
|
||||
case err == nil:
|
||||
return resp, checkResponseErr(resp)
|
||||
default:
|
||||
if err != nil {
|
||||
// Failed to connect or context error.
|
||||
return resp, err
|
||||
}
|
||||
|
||||
// Successfully made a request; return the response and handle any
|
||||
// API HTTP response errors.
|
||||
return resp, checkResponseErr(resp)
|
||||
}
|
||||
|
||||
// doRequest sends an HTTP request and returns an HTTP response. It is a
|
||||
|
||||
Reference in New Issue
Block a user