mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
client/request: wrap some errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
f76d6a078d
commit
744940056d
1 changed files with 5 additions and 5 deletions
|
@ -136,7 +136,7 @@ func (cli *Client) doRequest(ctx context.Context, req *http.Request) (serverResp
|
|||
}
|
||||
|
||||
if cli.scheme == "https" && strings.Contains(err.Error(), "bad certificate") {
|
||||
return serverResp, fmt.Errorf("The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings: %v", err)
|
||||
return serverResp, errors.Wrap(err, "The server probably has client authentication (--tlsverify) enabled. Please check your TLS client certification settings")
|
||||
}
|
||||
|
||||
// Don't decorate context sentinel errors; users may be comparing to
|
||||
|
@ -220,14 +220,14 @@ func (cli *Client) checkResponseErr(serverResp serverResponse) error {
|
|||
if (cli.version == "" || versions.GreaterThan(cli.version, "1.23")) && ct == "application/json" {
|
||||
var errorResponse types.ErrorResponse
|
||||
if err := json.Unmarshal(body, &errorResponse); err != nil {
|
||||
return fmt.Errorf("Error reading JSON: %v", err)
|
||||
return errors.Wrap(err, "Error reading JSON")
|
||||
}
|
||||
errorMessage = errorResponse.Message
|
||||
errorMessage = strings.TrimSpace(errorResponse.Message)
|
||||
} else {
|
||||
errorMessage = string(body)
|
||||
errorMessage = strings.TrimSpace(string(body))
|
||||
}
|
||||
|
||||
return fmt.Errorf("Error response from daemon: %s", strings.TrimSpace(errorMessage))
|
||||
return errors.Wrap(errors.New(errorMessage), "Error response from daemon")
|
||||
}
|
||||
|
||||
func (cli *Client) addHeaders(req *http.Request, headers headers) *http.Request {
|
||||
|
|
Loading…
Reference in a new issue