Skip to content

Commit

Permalink
oops missing error check
Browse files Browse the repository at this point in the history
  • Loading branch information
jharley committed Nov 16, 2023
1 parent b852f1a commit 3cc485d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
24 changes: 13 additions & 11 deletions internal/provider/burn_alert_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}
}
24 changes: 13 additions & 11 deletions internal/provider/trigger_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}
}

Expand Down

0 comments on commit 3cc485d

Please sign in to comment.