@@ -87,11 +87,18 @@ func resourceSentryOrganizationMemberCreate(ctx context.Context, d *schema.Resou
87
87
"email" : params .Email ,
88
88
"org" : org ,
89
89
})
90
+
90
91
httpResp , err := apiClient .CreateOrganizationMemberWithResponse (ctx , org , params )
91
92
if err != nil {
92
93
return diag .FromErr (err )
93
- } else if httpResp .StatusCode () != http .StatusCreated || httpResp .JSON201 == nil {
94
- return diag .FromErr (fmt .Errorf ("unexpected status code: %d" , httpResp .StatusCode ()))
94
+ }
95
+
96
+ if httpResp .StatusCode () != http .StatusCreated {
97
+ return diag .FromErr (fmt .Errorf ("failed to create organization member, got status %d: %s" , httpResp .StatusCode (), string (httpResp .Body )))
98
+ }
99
+
100
+ if httpResp .JSON201 == nil {
101
+ return diag .FromErr (fmt .Errorf ("failed to create organization member: empty response body" ))
95
102
}
96
103
97
104
member := httpResp .JSON201
@@ -115,11 +122,19 @@ func resourceSentryOrganizationMemberRead(ctx context.Context, d *schema.Resourc
115
122
httpResp , err := apiClient .GetOrganizationMemberWithResponse (ctx , org , memberID )
116
123
if err != nil {
117
124
return diag .FromErr (err )
118
- } else if httpResp .StatusCode () == http .StatusNotFound {
125
+ }
126
+
127
+ if httpResp .StatusCode () == http .StatusNotFound {
119
128
d .SetId ("" )
120
129
return nil
121
- } else if httpResp .StatusCode () != http .StatusOK || httpResp .JSON200 == nil {
122
- return diag .FromErr (fmt .Errorf ("unexpected status code: %d" , httpResp .StatusCode ()))
130
+ }
131
+
132
+ if httpResp .StatusCode () != http .StatusOK {
133
+ return diag .FromErr (fmt .Errorf ("failed to read organization member, got status %d: %s" , httpResp .StatusCode (), string (httpResp .Body )))
134
+ }
135
+
136
+ if httpResp .JSON200 == nil {
137
+ return diag .FromErr (fmt .Errorf ("failed to read organization member: empty response body" ))
123
138
}
124
139
125
140
member := httpResp .JSON200
@@ -147,8 +162,14 @@ func resourceSentryOrganizationMemberUpdate(ctx context.Context, d *schema.Resou
147
162
getHttpResp , err := apiClient .GetOrganizationMemberWithResponse (ctx , org , memberID )
148
163
if err != nil {
149
164
return diag .FromErr (err )
150
- } else if getHttpResp .StatusCode () != http .StatusOK || getHttpResp .JSON200 == nil {
151
- return diag .FromErr (fmt .Errorf ("unexpected status code: %d" , getHttpResp .StatusCode ()))
165
+ }
166
+
167
+ if getHttpResp .StatusCode () != http .StatusOK {
168
+ return diag .FromErr (fmt .Errorf ("failed to read organization member for update, got status %d: %s" , getHttpResp .StatusCode (), string (getHttpResp .Body )))
169
+ }
170
+
171
+ if getHttpResp .JSON200 == nil {
172
+ return diag .FromErr (fmt .Errorf ("failed to read organization member for update: empty response body" ))
152
173
}
153
174
orgMember := getHttpResp .JSON200
154
175
@@ -174,8 +195,14 @@ func resourceSentryOrganizationMemberUpdate(ctx context.Context, d *schema.Resou
174
195
httpResp , err := apiClient .UpdateOrganizationMemberWithResponse (ctx , org , memberID , params )
175
196
if err != nil {
176
197
return diag .FromErr (err )
177
- } else if httpResp .StatusCode () != http .StatusOK || httpResp .JSON200 == nil {
178
- return diag .FromErr (fmt .Errorf ("unexpected status code: %d" , httpResp .StatusCode ()))
198
+ }
199
+
200
+ if httpResp .StatusCode () != http .StatusOK {
201
+ return diag .FromErr (fmt .Errorf ("failed to update organization member, got status %d: %s" , httpResp .StatusCode (), string (httpResp .Body )))
202
+ }
203
+
204
+ if httpResp .JSON200 == nil {
205
+ return diag .FromErr (fmt .Errorf ("failed to update organization member: empty response body" ))
179
206
}
180
207
181
208
member := httpResp .JSON200
@@ -199,8 +226,10 @@ func resourceSentryOrganizationMemberDelete(ctx context.Context, d *schema.Resou
199
226
httpResp , err := apiClient .DeleteOrganizationMemberWithResponse (ctx , org , memberID )
200
227
if err != nil {
201
228
return diag .FromErr (err )
202
- } else if httpResp .StatusCode () != http .StatusNoContent {
203
- return diag .FromErr (fmt .Errorf ("unexpected status code: %d" , httpResp .StatusCode ()))
229
+ }
230
+
231
+ if httpResp .StatusCode () != http .StatusNoContent {
232
+ return diag .FromErr (fmt .Errorf ("failed to delete organization member, got status %d: %s" , httpResp .StatusCode (), string (httpResp .Body )))
204
233
}
205
234
206
235
return nil
0 commit comments