diff --git a/client/container_logs.go b/client/container_logs.go index 35c297c5fb..562c8b4bcc 100644 --- a/client/container_logs.go +++ b/client/container_logs.go @@ -74,7 +74,7 @@ func (cli *Client) ContainerLogs(ctx context.Context, container string, options resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil) if err != nil { - return nil, err + return nil, wrapResponseError(err, resp, "container", container) } return resp.body, nil } diff --git a/client/container_logs_test.go b/client/container_logs_test.go index 8cb7635120..41849cf576 100644 --- a/client/container_logs_test.go +++ b/client/container_logs_test.go @@ -18,6 +18,16 @@ import ( "golang.org/x/net/context" ) +func TestContainerLogsNotFoundError(t *testing.T) { + client := &Client{ + client: newMockClient(errorMock(http.StatusNotFound, "Not found")), + } + _, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{}) + if !IsErrNotFound(err) { + t.Fatalf("expected a not found error, got %v", err) + } +} + func TestContainerLogsError(t *testing.T) { client := &Client{ client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),