Skip to content

Commit

Permalink
Improve table import error handling (#365)
Browse files Browse the repository at this point in the history
When there is an error importing a table, then the HTTP response body is
probably nil so we shouldn't try to read it.
Fixes: #355
  • Loading branch information
pgier authored Feb 21, 2024
1 parent e42b39b commit 034a358
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/provider/resource_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ func resourceTableRead(ctx context.Context, d *schema.ResourceData, meta interfa
}
resp, err := restClient.GetTable(ctx, keyspaceName, tableName, &params)
if err != nil {
b, _ := io.ReadAll(resp.Body)
return diag.FromErr(fmt.Errorf("Error getting table (not retrying) err: %s, body: %s", err, b))
return diag.FromErr(fmt.Errorf("error getting table (not retrying) err: %w", err))
} else if resp.StatusCode == 409 {
// DevOps API returns 409 for concurrent modifications, these need to be retried.
b, _ := io.ReadAll(resp.Body)
Expand Down

0 comments on commit 034a358

Please sign in to comment.