Skip to content

Commit 1370df5

Browse files
authored
Inbox 2228/use error codes again (#271)
1 parent 7db0f0b commit 1370df5

7 files changed

Lines changed: 8 additions & 7 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/go-retryablehttp v0.7.1
88
github.com/hashicorp/terraform-plugin-sdk v1.17.2
99
github.com/stretchr/testify v1.7.0
10-
gopkg.in/ns1/ns1-go.v2 v2.7.2
10+
gopkg.in/ns1/ns1-go.v2 v2.7.3
1111
)
1212

1313
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
661661
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
662662
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
663663
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
664-
gopkg.in/ns1/ns1-go.v2 v2.7.2 h1:UxwltdwgxWR1oK44eK2bYkSaZD/eq7jUMgrSH4HTApk=
665-
gopkg.in/ns1/ns1-go.v2 v2.7.2/go.mod h1:GMnKY+ZuoJ+lVLL+78uSTjwTz2jMazq6AfGKQOYhsPk=
664+
gopkg.in/ns1/ns1-go.v2 v2.7.3 h1:YZ1YfVEk4eU9AoJsUjIi67Kv61LfZixQoRceWScDDvY=
665+
gopkg.in/ns1/ns1-go.v2 v2.7.3/go.mod h1:GMnKY+ZuoJ+lVLL+78uSTjwTz2jMazq6AfGKQOYhsPk=
666666
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
667667
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
668668
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

ns1/resource_apikey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func ApikeyRead(d *schema.ResourceData, meta interface{}) error {
131131
client := meta.(*ns1.Client)
132132
k, resp, err := client.APIKeys.Get(d.Id())
133133
if err != nil {
134-
if resp != nil && resp.StatusCode == 404 {
134+
if err == ns1.ErrKeyMissing {
135135
log.Printf("[DEBUG] NS1 API key (%s) not found", d.Id())
136136
d.SetId("")
137137
return nil

ns1/resource_monitoringjob.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ func MonitoringJobRead(d *schema.ResourceData, meta interface{}) error {
280280
client := meta.(*ns1.Client)
281281
j, resp, err := client.Jobs.Get(d.Id())
282282
if err != nil {
283+
// No custom error type is currently defined in the SDK for a monitoring job.
283284
if resp != nil && resp.StatusCode == 404 {
284285
log.Printf("[DEBUG] NS1 record (%s) not found", d.Id())
285286
d.SetId("")

ns1/resource_notifylist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func NotifyListRead(d *schema.ResourceData, meta interface{}) error {
141141

142142
nl, resp, err := client.Notifications.Get(d.Id())
143143
if err != nil {
144-
if resp != nil && resp.StatusCode == 404 {
144+
if err == ns1.ErrListMissing {
145145
log.Printf("[DEBUG] NS1 notify list (%s) not found", d.Id())
146146
d.SetId("")
147147
return nil

ns1/resource_team.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func TeamRead(d *schema.ResourceData, meta interface{}) error {
121121
client := meta.(*ns1.Client)
122122
t, resp, err := client.Teams.Get(d.Id())
123123
if err != nil {
124-
if resp != nil && resp.StatusCode == 404 {
124+
if err == ns1.ErrTeamMissing {
125125
log.Printf("[DEBUG] NS1 team (%s) not found", d.Id())
126126
d.SetId("")
127127
return nil

ns1/resource_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func UserRead(d *schema.ResourceData, meta interface{}) error {
151151
client := meta.(*ns1.Client)
152152
u, resp, err := client.Users.Get(d.Id())
153153
if err != nil {
154-
if resp != nil && resp.StatusCode == 404 {
154+
if err == ns1.ErrUserMissing {
155155
log.Printf("[DEBUG] NS1 user (%s) not found", d.Id())
156156
d.SetId("")
157157
return nil

0 commit comments

Comments
 (0)