From 92630b806732e39f19b16c64a803e6c311e762f9 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 8 Sep 2016 15:37:45 -0700 Subject: [PATCH] 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 Upstream-commit: 450b3123e30d7920b2e7203a546483f06e9ad4d1 Component: cli --- components/cli/request.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/cli/request.go b/components/cli/request.go index 024e973520..7b4f5406b8 100644 --- a/components/cli/request.go +++ b/components/cli/request.go @@ -14,6 +14,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client/transport/cancellable" + "github.com/pkg/errors" "golang.org/x/net/context" ) @@ -131,7 +132,8 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q } } } - return serverResp, fmt.Errorf("An error occurred trying to connect: %v", err) + + return serverResp, errors.Wrap(err, "error during connect") } if resp != nil {