From 3cc485dbd81c87dc2e03c696e96a274e979c2387 Mon Sep 17 00:00:00 2001 From: Jason Harley Date: Thu, 16 Nov 2023 17:16:29 -0500 Subject: [PATCH] oops missing error check --- internal/provider/burn_alert_resource.go | 24 +++++++++++++----------- internal/provider/trigger_resource.go | 24 +++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/internal/provider/burn_alert_resource.go b/internal/provider/burn_alert_resource.go index 3476fe74..043647f1 100644 --- a/internal/provider/burn_alert_resource.go +++ b/internal/provider/burn_alert_resource.go @@ -437,18 +437,20 @@ func (r *burnAlertResource) Delete(ctx context.Context, req resource.DeleteReque // Delete the burn alert, using the values from state var detailedErr client.DetailedError err := r.client.BurnAlerts.Delete(ctx, state.Dataset.ValueString(), state.ID.ValueString()) - if errors.As(err, &detailedErr) { - // if not found consider it deleted -- so don't error - if !detailedErr.IsNotFound() { - resp.Diagnostics.Append(helper.NewDetailedErrorDiagnostic( + if err != nil { + if errors.As(err, &detailedErr) { + // if not found consider it deleted -- so don't error + if !detailedErr.IsNotFound() { + resp.Diagnostics.Append(helper.NewDetailedErrorDiagnostic( + "Error Deleting Honeycomb Burn Alert", + &detailedErr, + )) + } + } else { + resp.Diagnostics.AddError( "Error Deleting Honeycomb Burn Alert", - &detailedErr, - )) + "Could not delete Burn Alert ID "+state.ID.ValueString()+": "+err.Error(), + ) } - } else { - resp.Diagnostics.AddError( - "Error Deleting Honeycomb Burn Alert", - "Could not delete Burn Alert ID "+state.ID.ValueString()+": "+err.Error(), - ) } } diff --git a/internal/provider/trigger_resource.go b/internal/provider/trigger_resource.go index a1dc36f2..f157dad7 100644 --- a/internal/provider/trigger_resource.go +++ b/internal/provider/trigger_resource.go @@ -379,19 +379,21 @@ func (r *triggerResource) Delete(ctx context.Context, req resource.DeleteRequest var detailedErr client.DetailedError err := r.client.Triggers.Delete(ctx, state.Dataset.ValueString(), state.ID.ValueString()) - if errors.As(err, &detailedErr) { - // if not found consider it deleted -- so don't error - if !detailedErr.IsNotFound() { - resp.Diagnostics.Append(helper.NewDetailedErrorDiagnostic( + if err != nil { + if errors.As(err, &detailedErr) { + // if not found consider it deleted -- so don't error + if !detailedErr.IsNotFound() { + resp.Diagnostics.Append(helper.NewDetailedErrorDiagnostic( + "Error Deleting Honeycomb Trigger", + &detailedErr, + )) + } + } else { + resp.Diagnostics.AddError( "Error Deleting Honeycomb Trigger", - &detailedErr, - )) + "Could not delete Trigger ID "+state.ID.ValueString()+": "+err.Error(), + ) } - } else { - resp.Diagnostics.AddError( - "Error Deleting Honeycomb Trigger", - "Could not delete Trigger ID "+state.ID.ValueString()+": "+err.Error(), - ) } }