Skip to content

Commit

Permalink
Improve error handling in account read and delete functions
Browse files Browse the repository at this point in the history
This commit eliminates a redundant variable declaration from the
resourceCloudflareAccountRead function and surfaces some additional
information (the account ID) on account deletion failure cases.

Closes #2437

```release-note:enhancement
resource/cloudflare_account: Improve error handling of resourceCloudflareAccountDelete
```
  • Loading branch information
therealdwright committed May 17, 2023
1 parent 483e9b5 commit 0da1d08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/2436.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/cloudflare_account: Improve error handling of resourceCloudflareAccountDelete
```
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func resourceCloudflareKeysConfigurationImport(ctx context.Context, d *schema.Re
d.SetId(accountID)
d.Set(consts.AccountIDSchemaKey, accountID)

resourceCloudflareAccessKeysConfigurationRead(ctx, d, meta)
if err := resourceCloudflareAccessKeysConfigurationRead(ctx, d, meta); err != nil {
return nil, err
}

return []*schema.ResourceData{d}, nil
}
2 changes: 1 addition & 1 deletion internal/sdkv2provider/resource_cloudflare_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func resourceCloudflareAccountDelete(ctx context.Context, d *schema.ResourceData
err := client.DeleteAccount(ctx, accountID)

if err != nil {
return diag.FromErr(fmt.Errorf("error deleting Cloudflare Account: %w", err))
return diag.FromErr(fmt.Errorf("error deleting Cloudflare Account %q: %w", accountID, err))
}

return nil
Expand Down

0 comments on commit 0da1d08

Please sign in to comment.