From 034a3585dfbf3ca87e8e771e7153855b627d9494 Mon Sep 17 00:00:00 2001 From: Paul Gier Date: Wed, 21 Feb 2024 08:08:20 -0600 Subject: [PATCH] Improve table import error handling (#365) 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 --- internal/provider/resource_table.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/provider/resource_table.go b/internal/provider/resource_table.go index 03627dd..26da09b 100644 --- a/internal/provider/resource_table.go +++ b/internal/provider/resource_table.go @@ -246,8 +246,7 @@ func resourceTableRead(ctx context.Context, d *schema.ResourceData, meta interfa } resp, err := restClient.GetTable(ctx, keyspaceName, tableName, ¶ms) 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)