Skip to content

Commit 8e5ef8a

Browse files
committed
client: don't hide context errors
Instead of reformatting error from the request action, we wrap it, allowing the cause to be recovered. This is important for consumers that need to be able to detect context errors, such as `Cancelled` and `DeadlineExceeded`. Signed-off-by: Stephen J Day <stephen.day@docker.com>
1 parent 93e8aff commit 8e5ef8a

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

client/request.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/docker/docker/api/types"
1515
"github.com/docker/docker/api/types/versions"
1616
"github.com/docker/docker/client/transport/cancellable"
17+
"github.com/pkg/errors"
1718
"golang.org/x/net/context"
1819
)
1920

@@ -131,7 +132,8 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
131132
}
132133
}
133134
}
134-
return serverResp, fmt.Errorf("An error occurred trying to connect: %v", err)
135+
136+
return serverResp, errors.Wrap(err, "error during connect")
135137
}
136138

137139
if resp != nil {

integration-cli/docker_cli_daemon_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,7 @@ func (s *DockerDaemonSuite) TestDaemonNoTlsCliTlsVerifyWithEnv(c *check.C) {
17031703
cmd.Env = []string{"DOCKER_TLS_VERIFY=1", "DOCKER_CERT_PATH=fixtures/https"}
17041704
out, _, err := runCommandWithOutput(cmd)
17051705
c.Assert(err, check.Not(check.IsNil), check.Commentf("%s", out))
1706-
c.Assert(strings.Contains(out, "error occurred trying to connect"), check.Equals, true)
1706+
c.Assert(strings.Contains(out, "error during connect"), check.Equals, true)
17071707

17081708
}
17091709

integration-cli/docker_cli_run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@ func (s *DockerSuite) TestRunTLSverify(c *check.C) {
26622662
// Regardless of whether we specify true or false we need to
26632663
// test to make sure tls is turned on if --tlsverify is specified at all
26642664
result := dockerCmdWithResult("--tlsverify=false", "ps")
2665-
result.Assert(c, icmd.Expected{ExitCode: 1, Err: "trying to connect"})
2665+
result.Assert(c, icmd.Expected{ExitCode: 1, Err: "error during connect"})
26662666

26672667
result = dockerCmdWithResult("--tlsverify=true", "ps")
26682668
result.Assert(c, icmd.Expected{ExitCode: 1, Err: "cert"})

0 commit comments

Comments
 (0)