From 9692885aa2924abede5b23df3861c14145e25de7 Mon Sep 17 00:00:00 2001 From: haruska <2803+haruska@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:32:04 -0500 Subject: [PATCH] return response body on unexpected error responses --- pinecone/management_client.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pinecone/management_client.go b/pinecone/management_client.go index be11afa..abdb092 100644 --- a/pinecone/management_client.go +++ b/pinecone/management_client.go @@ -167,7 +167,7 @@ func (c *ManagementClient) ListProjects(ctx context.Context) ([]*Project, error) case http.StatusInternalServerError: return nil, fmt.Errorf("internal server error: %v", resp.JSON500) default: - return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return nil, fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } return nil, fmt.Errorf("unexpected response format or empty data") @@ -212,7 +212,7 @@ func (c *ManagementClient) FetchProject(ctx context.Context, projectId uuid.UUID case http.StatusInternalServerError: return nil, fmt.Errorf("internal server error: %v", resp.JSON500) default: - return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return nil, fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } return nil, fmt.Errorf("unexpected response format or empty data") @@ -259,7 +259,7 @@ func (c *ManagementClient) CreateProject(ctx context.Context, projectName string case http.StatusBadRequest: return nil, fmt.Errorf("bad request: %v", resp.JSON400) default: - return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return nil, fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } return nil, fmt.Errorf("unexpected response format or empty data") @@ -297,7 +297,7 @@ func (c *ManagementClient) DeleteProject(ctx context.Context, projectId uuid.UUI case http.StatusInternalServerError: return fmt.Errorf("internal server error: %v", resp.JSON500) default: - return fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } } @@ -347,7 +347,7 @@ func (c *ManagementClient) ListApiKeys(ctx context.Context, projectId uuid.UUID) case http.StatusInternalServerError: return nil, fmt.Errorf("internal server error: %v", resp.JSON500) default: - return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return nil, fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } } @@ -394,7 +394,7 @@ func (c *ManagementClient) FetchApiKey(ctx context.Context, apiKeyId uuid.UUID) case http.StatusInternalServerError: return nil, fmt.Errorf("internal server error: %v", resp.JSON500) default: - return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return nil, fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } return nil, fmt.Errorf("unexpected response format or empty data") @@ -451,7 +451,7 @@ func (c *ManagementClient) CreateApiKey(ctx context.Context, projectId uuid.UUID case http.StatusBadRequest: return nil, fmt.Errorf("bad request: %v", resp.JSON400) default: - return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return nil, fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } return nil, fmt.Errorf("unexpected response format or empty data") @@ -495,6 +495,6 @@ func (c *ManagementClient) DeleteApiKey(ctx context.Context, apiKeyId uuid.UUID) case http.StatusInternalServerError: return fmt.Errorf("internal server error: %v", resp.JSON500) default: - return fmt.Errorf("unexpected status code: %d", resp.StatusCode()) + return fmt.Errorf("unexpected status code: %d; response body: %s", resp.StatusCode(), string(resp.Body)) } }