Skip to content

Commit 58c5774

Browse files
authored
Handle nil response from SDK (#33)
1 parent 024666a commit 58c5774

17 files changed

+44
-40
lines changed

internal/provider/destination_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (d *destinationDataSource) Read(ctx context.Context, req datasource.ReadReq
7979
if err != nil {
8080
resp.Diagnostics.AddError(
8181
"Unable to Read Destination",
82-
getError(err, body.Body),
82+
getError(err, body),
8383
)
8484
return
8585
}

internal/provider/destination_metadata_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func (d *destinationMetadataDataSource) Read(ctx context.Context, req datasource
399399
if err != nil {
400400
resp.Diagnostics.AddError(
401401
"Unable to Read Source metadata",
402-
getError(err, body.Body),
402+
getError(err, body),
403403
)
404404
return
405405
}

internal/provider/destination_resource.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func (r *destinationResource) Create(ctx context.Context, req resource.CreateReq
538538
if err != nil {
539539
resp.Diagnostics.AddError(
540540
"Unable to create Destination",
541-
getError(err, body.Body),
541+
getError(err, body),
542542
)
543543
return
544544
}
@@ -579,7 +579,7 @@ func (r *destinationResource) Read(ctx context.Context, req resource.ReadRequest
579579
if err != nil {
580580
resp.Diagnostics.AddError(
581581
"Unable to read Destination",
582-
getError(err, body.Body),
582+
getError(err, body),
583583
)
584584
return
585585
}
@@ -636,7 +636,7 @@ func (r *destinationResource) Update(ctx context.Context, req resource.UpdateReq
636636
if err != nil {
637637
resp.Diagnostics.AddError(
638638
"Unable to update Destination",
639-
getError(err, body.Body),
639+
getError(err, body),
640640
)
641641
return
642642
}
@@ -677,7 +677,7 @@ func (r *destinationResource) Delete(ctx context.Context, req resource.DeleteReq
677677
_, body, err := r.client.DestinationsApi.DeleteDestination(r.authContext, state.ID.ValueString()).Execute()
678678
if err != nil {
679679
resp.Diagnostics.AddError(
680-
"Error deleting Destination", "Could not delete Destination, unexpected error: "+getError(err, body.Body),
680+
"Error deleting Destination", "Could not delete Destination, unexpected error: "+getError(err, body),
681681
)
682682
return
683683
}

internal/provider/label_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (r *labelResource) Create(ctx context.Context, req resource.CreateRequest,
121121
if err != nil {
122122
resp.Diagnostics.AddError(
123123
"Unable to Create a label",
124-
getError(err, body.Body),
124+
getError(err, body),
125125
)
126126
return
127127
}
@@ -156,7 +156,7 @@ func (r *labelResource) Read(ctx context.Context, req resource.ReadRequest, resp
156156
if err != nil {
157157
resp.Diagnostics.AddError(
158158
"Unable to Read Labels",
159-
getError(err, body.Body),
159+
getError(err, body),
160160
)
161161
return
162162
}
@@ -203,7 +203,7 @@ func (r *labelResource) Delete(ctx context.Context, req resource.DeleteRequest,
203203
_, body, err := r.client.LabelsApi.DeleteLabel(r.authContext, state.Key.ValueString(), state.Value.ValueString()).Execute()
204204
if err != nil {
205205
resp.Diagnostics.AddError(
206-
"Error Deleting a Label", "Could not delete a label, unexpected error: "+getError(err, body.Body),
206+
"Error Deleting a Label", "Could not delete a label, unexpected error: "+getError(err, body),
207207
)
208208
return
209209
}

internal/provider/source_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (d *sourceDataSource) Read(ctx context.Context, req datasource.ReadRequest,
202202
if err != nil {
203203
resp.Diagnostics.AddError(
204204
"Unable to Read Source",
205-
getError(err, body.Body),
205+
getError(err, body),
206206
)
207207
return
208208
}

internal/provider/source_metadata_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (d *sourceMetadataDataSource) Read(ctx context.Context, req datasource.Read
5151
if err != nil {
5252
resp.Diagnostics.AddError(
5353
"Unable to Read Source metadata",
54-
getError(err, body.Body),
54+
getError(err, body),
5555
)
5656
return
5757
}

internal/provider/source_resource.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (r *sourceResource) Create(ctx context.Context, req resource.CreateRequest,
265265
if err != nil {
266266
resp.Diagnostics.AddError(
267267
"Unable to create Source",
268-
getError(err, body.Body),
268+
getError(err, body),
269269
)
270270
return
271271
}
@@ -280,7 +280,7 @@ func (r *sourceResource) Create(ctx context.Context, req resource.CreateRequest,
280280
if err != nil {
281281
resp.Diagnostics.AddError(
282282
"Unable to create Source",
283-
getError(err, body.Body),
283+
getError(err, body),
284284
)
285285
return
286286
}
@@ -321,7 +321,7 @@ func (r *sourceResource) Read(ctx context.Context, req resource.ReadRequest, res
321321
if err != nil {
322322
resp.Diagnostics.AddError(
323323
"Unable to read Source",
324-
getError(err, body.Body),
324+
getError(err, body),
325325
)
326326
return
327327
}
@@ -378,7 +378,7 @@ func (r *sourceResource) Update(ctx context.Context, req resource.UpdateRequest,
378378
if err != nil {
379379
resp.Diagnostics.AddError(
380380
"Unable to update Source",
381-
getError(err, body.Body),
381+
getError(err, body),
382382
)
383383
return
384384
}
@@ -399,7 +399,7 @@ func (r *sourceResource) Update(ctx context.Context, req resource.UpdateRequest,
399399
if err != nil {
400400
resp.Diagnostics.AddError(
401401
"Unable to update Source",
402-
getError(err, body.Body),
402+
getError(err, body),
403403
)
404404
return
405405
}
@@ -437,7 +437,7 @@ func (r *sourceResource) Delete(ctx context.Context, req resource.DeleteRequest,
437437
if err != nil {
438438
resp.Diagnostics.AddError(
439439
"Unable to delete Source",
440-
getError(err, body.Body),
440+
getError(err, body),
441441
)
442442
return
443443
}

internal/provider/source_warehouse_connection_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (r *sourceWarehouseConnectionResource) Create(ctx context.Context, req reso
7070
if err != nil {
7171
resp.Diagnostics.AddError(
7272
"Unable to create connection between Source and Warehouse",
73-
getError(err, body.Body),
73+
getError(err, body),
7474
)
7575
return
7676
}
@@ -108,7 +108,7 @@ func (d *sourceWarehouseConnectionResource) Read(ctx context.Context, req resour
108108
if err != nil {
109109
resp.Diagnostics.AddError(
110110
"Unable to read Source-Warehouse connection",
111-
getError(err, body.Body),
111+
getError(err, body),
112112
)
113113
return
114114
}
@@ -158,7 +158,7 @@ func (r *sourceWarehouseConnectionResource) Delete(ctx context.Context, req reso
158158
if err != nil {
159159
resp.Diagnostics.AddError(
160160
"Unable to remove Source-Warehouse connection",
161-
getError(err, body.Body),
161+
getError(err, body),
162162
)
163163
return
164164
}

internal/provider/tracking_plan_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (d *trackingPlanDataSource) Read(ctx context.Context, req datasource.ReadRe
9595
if err != nil {
9696
resp.Diagnostics.AddError(
9797
"Unable to read Tracking Plan",
98-
getError(err, body.Body),
98+
getError(err, body),
9999
)
100100
return
101101
}

internal/provider/tracking_plan_resource.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (r *trackingPlanResource) Create(ctx context.Context, req resource.CreateRe
9393
if err != nil {
9494
resp.Diagnostics.AddError(
9595
"Unable to create Tracking Plan",
96-
getError(err, body.Body),
96+
getError(err, body),
9797
)
9898
return
9999
}
@@ -130,7 +130,7 @@ func (r *trackingPlanResource) Read(ctx context.Context, req resource.ReadReques
130130
if err != nil {
131131
resp.Diagnostics.AddError(
132132
"Unable to read Tracking Plan",
133-
getError(err, body.Body),
133+
getError(err, body),
134134
)
135135
return
136136
}
@@ -186,7 +186,7 @@ func (r *trackingPlanResource) Update(ctx context.Context, req resource.UpdateRe
186186
if err != nil {
187187
resp.Diagnostics.AddError(
188188
"Unable to update Tracking Plan",
189-
getError(err, body.Body),
189+
getError(err, body),
190190
)
191191
return
192192
}
@@ -195,7 +195,7 @@ func (r *trackingPlanResource) Update(ctx context.Context, req resource.UpdateRe
195195
if err != nil {
196196
resp.Diagnostics.AddError(
197197
"Unable to read Tracking Plan",
198-
getError(err, body.Body),
198+
getError(err, body),
199199
)
200200
return
201201
}
@@ -231,7 +231,7 @@ func (r *trackingPlanResource) Delete(ctx context.Context, req resource.DeleteRe
231231
if err != nil {
232232
resp.Diagnostics.AddError(
233233
"Unable to delete Tracking Plan",
234-
getError(err, body.Body),
234+
getError(err, body),
235235
)
236236
return
237237
}

0 commit comments

Comments
 (0)