Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
Add resource ID to notification rule/contact method error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Wilczyński committed Feb 24, 2021
1 parent 0f8ac8c commit ba73381
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pagerduty/resource_pagerduty_user_contact_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func resourcePagerDutyUserContactMethodCreate(d *schema.ResourceData, meta inter

resp, _, err := client.Users.CreateContactMethod(userID, contactMethod)
if err != nil {
return err
return fmt.Errorf("Error while creating contact method %s: %w", contactMethod.ID, err)
}

d.SetId(resp.ID)
Expand All @@ -120,7 +120,7 @@ func resourcePagerDutyUserContactMethodRead(d *schema.ResourceData, meta interfa
errResp := handleNotFoundError(err, d)
if errResp != nil {
time.Sleep(10 * time.Second)
return resource.RetryableError(errResp)
return resource.RetryableError(fmt.Errorf("Error while reading contact method %s: %w", d.Id(), err))
}

return nil
Expand Down Expand Up @@ -148,7 +148,7 @@ func resourcePagerDutyUserContactMethodUpdate(d *schema.ResourceData, meta inter
userID := d.Get("user_id").(string)

if _, _, err := client.Users.UpdateContactMethod(userID, d.Id(), contactMethod); err != nil {
return err
return fmt.Errorf("Error while updating contact method %s: %w", contactMethod.ID, err)
}

return resourcePagerDutyUserContactMethodRead(d, meta)
Expand Down
6 changes: 3 additions & 3 deletions pagerduty/resource_pagerduty_user_notification_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func resourcePagerDutyUserNotificationRuleCreate(d *schema.ResourceData, meta in

resp, _, err := client.Users.CreateNotificationRule(userID, notificationRule)
if err != nil {
return err
return fmt.Errorf("Error while creating notification rule %s: %w", notificationRule.ID, err)
}

d.SetId(resp.ID)
Expand All @@ -106,7 +106,7 @@ func resourcePagerDutyUserNotificationRuleRead(d *schema.ResourceData, meta inte
errResp := handleNotFoundError(err, d)
if errResp != nil {
time.Sleep(10 * time.Second)
return resource.RetryableError(errResp)
return resource.RetryableError(fmt.Errorf("Error while reading notification rule %s: %w", d.Id(), err))
}

return nil
Expand All @@ -131,7 +131,7 @@ func resourcePagerDutyUserNotificationRuleUpdate(d *schema.ResourceData, meta in
userID := d.Get("user_id").(string)

if _, _, err := client.Users.UpdateNotificationRule(userID, d.Id(), contactMethod); err != nil {
return err
return fmt.Errorf("Error while updating notification rule %s: %w", d.Id(), err)
}

return resourcePagerDutyUserNotificationRuleRead(d, meta)
Expand Down

0 comments on commit ba73381

Please sign in to comment.