From 71586e2d96f9348cdf786ed614f8c2214feae6af Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Thu, 12 Dec 2024 10:34:28 -0500 Subject: [PATCH] Tidy up error messages. --- internal/service/sesv2/configuration_set.go | 13 +++++++------ .../service/sesv2/configuration_set_data_source.go | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/service/sesv2/configuration_set.go b/internal/service/sesv2/configuration_set.go index 1a9be61fe56..3801d519173 100644 --- a/internal/service/sesv2/configuration_set.go +++ b/internal/service/sesv2/configuration_set.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/create" "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" + "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" @@ -268,42 +269,42 @@ func resourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, m d.Set("configuration_set_name", output.ConfigurationSetName) if output.DeliveryOptions != nil { if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(output.DeliveryOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting delivery_options: %s", err) } } else { d.Set("delivery_options", nil) } if output.ReputationOptions != nil { if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(output.ReputationOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting reputation_options: %s", err) } } else { d.Set("reputation_options", nil) } if output.SendingOptions != nil { if err := d.Set("sending_options", []interface{}{flattenSendingOptions(output.SendingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting sending_options: %s", err) } } else { d.Set("sending_options", nil) } if output.SuppressionOptions != nil { if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(output.SuppressionOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting suppression_options: %s", err) } } else { d.Set("suppression_options", nil) } if output.TrackingOptions != nil { if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(output.TrackingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting tracking_options: %s", err) } } else { d.Set("tracking_options", nil) } if output.VdmOptions != nil { if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(output.VdmOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, resNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting vdm_options: %s", err) } } else { d.Set("vdm_options", nil) diff --git a/internal/service/sesv2/configuration_set_data_source.go b/internal/service/sesv2/configuration_set_data_source.go index fe5d2e773be..1938a940fc3 100644 --- a/internal/service/sesv2/configuration_set_data_source.go +++ b/internal/service/sesv2/configuration_set_data_source.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" + "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -170,42 +171,42 @@ func dataSourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, d.Set("configuration_set_name", output.ConfigurationSetName) if output.DeliveryOptions != nil { if err := d.Set("delivery_options", []interface{}{flattenDeliveryOptions(output.DeliveryOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting delivery_options: %s", err) } } else { d.Set("delivery_options", nil) } if output.ReputationOptions != nil { if err := d.Set("reputation_options", []interface{}{flattenReputationOptions(output.ReputationOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting reputation_options: %s", err) } } else { d.Set("reputation_options", nil) } if output.SendingOptions != nil { if err := d.Set("sending_options", []interface{}{flattenSendingOptions(output.SendingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting sending_options: %s", err) } } else { d.Set("sending_options", nil) } if output.SuppressionOptions != nil { if err := d.Set("suppression_options", []interface{}{flattenSuppressionOptions(output.SuppressionOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting suppression_options: %s", err) } } else { d.Set("suppression_options", nil) } if output.TrackingOptions != nil { if err := d.Set("tracking_options", []interface{}{flattenTrackingOptions(output.TrackingOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting tracking_options: %s", err) } } else { d.Set("tracking_options", nil) } if output.VdmOptions != nil { if err := d.Set("vdm_options", []interface{}{flattenVDMOptions(output.VdmOptions)}); err != nil { - return create.AppendDiagError(diags, names.SESV2, create.ErrActionSetting, dsNameConfigurationSet, d.Id(), err) + return sdkdiag.AppendErrorf(diags, "setting vdm_options: %s", err) } } else { d.Set("vdm_options", nil)