Skip to content

Commit

Permalink
return response body on unexpected error responses
Browse files Browse the repository at this point in the history
  • Loading branch information
haruska committed Apr 5, 2024
1 parent 675ff33 commit 9692885
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pinecone/management_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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))
}
}

0 comments on commit 9692885

Please sign in to comment.