Skip to content

Commit 84c3f55

Browse files
authored
fix(error-toolchain): update endpoint gateway resources and datasources (IBM-Cloud#6137)
* fix(error-toolchain): update endpoint gateway files * fix(error-toolchain): update dialog
1 parent 63af96a commit 84c3f55

5 files changed

+121
-67
lines changed

ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
package vpc
55

66
import (
7+
"context"
78
"fmt"
89
"log"
910

1011
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
1112
"github.com/IBM/vpc-go-sdk/vpcv1"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1214
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1315
)
1416

1517
func DataSourceIBMISEndpointGateway() *schema.Resource {
1618
return &schema.Resource{
17-
Read: dataSourceIBMISEndpointGatewayRead,
18-
Importer: &schema.ResourceImporter{},
19+
ReadContext: dataSourceIBMISEndpointGatewayRead,
20+
Importer: &schema.ResourceImporter{},
1921

2022
Schema: map[string]*schema.Schema{
2123
isVirtualEndpointGatewayName: {
@@ -176,10 +178,12 @@ func DataSourceIBMISEndpointGateway() *schema.Resource {
176178
}
177179

178180
func dataSourceIBMISEndpointGatewayRead(
179-
d *schema.ResourceData, meta interface{}) error {
181+
context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
180182
sess, err := vpcClient(meta)
181183
if err != nil {
182-
return err
184+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_is_virtual_endpoint_gateway", "read", "initialize-client")
185+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
186+
return tfErr.GetDiag()
183187
}
184188

185189
name := d.Get(isVirtualEndpointGatewayName).(string)
@@ -189,12 +193,18 @@ func dataSourceIBMISEndpointGatewayRead(
189193

190194
results, response, err := sess.ListEndpointGateways(options)
191195
if err != nil {
192-
return fmt.Errorf("[ERROR] Error fetching endpoint gateways %s\n%s", err, response)
196+
if err != nil {
197+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("ListEndpointGateways failed: %s\n%s", err.Error(), response), "(Data) ibm_is_virtual_endpoint_gateway", "read")
198+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
199+
return tfErr.GetDiag()
200+
}
193201
}
194202
allrecs := results.EndpointGateways
195203

196204
if len(allrecs) == 0 {
197-
return fmt.Errorf("[ERROR] No Virtual Endpoints Gateway found with given name %s", name)
205+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("ListEndpointGateways failed: %s", err.Error()), "(Data) ibm_is_virtual_endpoint_gateway", "read")
206+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
207+
return tfErr.GetDiag()
198208
}
199209
result := allrecs[0]
200210
d.SetId(*result.ID)
@@ -205,7 +215,7 @@ func dataSourceIBMISEndpointGatewayRead(
205215
d.Set(isVirtualEndpointGatewayCreatedAt, result.CreatedAt.String())
206216
d.Set(isVirtualEndpointGatewayLifecycleState, result.LifecycleState)
207217
if err := d.Set(isVirtualEndpointGatewayLifecycleReasons, resourceEGWFlattenLifecycleReasons(result.LifecycleReasons)); err != nil {
208-
return fmt.Errorf("[ERROR] Error setting lifecycle_reasons: %s", err)
218+
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_is_virtual_endpoint_gateway", "read", "lifecycle_reasons-to-map").GetDiag()
209219
}
210220
d.Set(isVirtualEndpointGatewayResourceType, result.ResourceType)
211221
d.Set(isVirtualEndpointGatewayIPs, flattenIPs(result.Ips))

ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateway_ips.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
package vpc
55

66
import (
7+
"context"
78
"fmt"
9+
"log"
810
"time"
911

1012
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
1113
"github.com/IBM/vpc-go-sdk/vpcv1"
14+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1215
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1316
)
1417

1518
func DataSourceIBMISEndpointGatewayIPs() *schema.Resource {
1619
return &schema.Resource{
17-
Read: dataSourceIBMISEndpointGatewayIPsRead,
18-
Importer: &schema.ResourceImporter{},
20+
ReadContext: dataSourceIBMISEndpointGatewayIPsRead,
21+
Importer: &schema.ResourceImporter{},
1922
Schema: map[string]*schema.Schema{
2023
isVirtualEndpointGatewayID: {
2124
Type: schema.TypeString,
@@ -87,10 +90,12 @@ func DataSourceIBMISEndpointGatewayIPs() *schema.Resource {
8790
}
8891
}
8992

90-
func dataSourceIBMISEndpointGatewayIPsRead(d *schema.ResourceData, meta interface{}) error {
93+
func dataSourceIBMISEndpointGatewayIPsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
9194
sess, err := vpcClient(meta)
9295
if err != nil {
93-
return err
96+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_is_virtual_endpoint_gateways_ips", "read", "initialize-client")
97+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
98+
return tfErr.GetDiag()
9499
}
95100
gatewayID := d.Get(isVirtualEndpointGatewayID).(string)
96101

@@ -103,7 +108,9 @@ func dataSourceIBMISEndpointGatewayIPsRead(d *schema.ResourceData, meta interfac
103108
}
104109
result, response, err := sess.ListEndpointGatewayIps(options)
105110
if err != nil {
106-
return fmt.Errorf("[ERROR] Error fetching endpoint gateway ips %s\n%s", err, response)
111+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("[ERROR] Error fetching endpoint gateway ips %s\n%s", err, response), "(Data) ibm_is_virtual_endpoint_gateways_ips", "read")
112+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
113+
return tfErr.GetDiag()
107114
}
108115
start = flex.GetNext(result.Next)
109116
allrecs = append(allrecs, result.Ips...)

ibm/service/vpc/data_source_ibm_is_virtual_endpoint_gateways.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
package vpc
55

66
import (
7+
"context"
78
"fmt"
89
"log"
910
"time"
1011

1112
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex"
1213
"github.com/IBM/vpc-go-sdk/vpcv1"
14+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1315
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1416
)
1517

@@ -20,8 +22,8 @@ const (
2022

2123
func DataSourceIBMISEndpointGateways() *schema.Resource {
2224
return &schema.Resource{
23-
Read: dataSourceIBMISEndpointGatewaysRead,
24-
Importer: &schema.ResourceImporter{},
25+
ReadContext: dataSourceIBMISEndpointGatewaysRead,
26+
Importer: &schema.ResourceImporter{},
2527
Schema: map[string]*schema.Schema{
2628
"resource_group": {
2729
Type: schema.TypeString,
@@ -198,12 +200,13 @@ func DataSourceIBMISEndpointGateways() *schema.Resource {
198200
}
199201
}
200202

201-
func dataSourceIBMISEndpointGatewaysRead(d *schema.ResourceData, meta interface{}) error {
203+
func dataSourceIBMISEndpointGatewaysRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
202204
sess, err := vpcClient(meta)
203205
if err != nil {
204-
return err
206+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "(Data) ibm_is_virtual_endpoint_gateways", "read", "initialize-client")
207+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
208+
return tfErr.GetDiag()
205209
}
206-
207210
start := ""
208211
allrecs := []vpcv1.EndpointGateway{}
209212
options := sess.NewListEndpointGatewaysOptions()
@@ -222,7 +225,9 @@ func dataSourceIBMISEndpointGatewaysRead(d *schema.ResourceData, meta interface{
222225
}
223226
result, response, err := sess.ListEndpointGateways(options)
224227
if err != nil {
225-
return fmt.Errorf("[ERROR] Error fetching endpoint gateways %s\n%s", err, response)
228+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("[ERROR] Error fetching endpoint gateways %s\n%s", err, response), "(Data) ibm_is_virtual_endpoint_gateways", "read")
229+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
230+
return tfErr.GetDiag()
226231
}
227232
start = flex.GetNext(result.Next)
228233
allrecs = append(allrecs, result.EndpointGateways...)

ibm/service/vpc/resource_ibm_is_virtual_endpoint_gateway.go

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate"
1616
"github.com/IBM/go-sdk-core/v5/core"
1717
"github.com/IBM/vpc-go-sdk/vpcv1"
18+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1819
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
1920
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
2021
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -51,12 +52,12 @@ func ResourceIBMISEndpointGateway() *schema.Resource {
5152
targetNameFmt := fmt.Sprintf("%s.0.%s", isVirtualEndpointGatewayTarget, isVirtualEndpointGatewayTargetName)
5253
targetCRNFmt := fmt.Sprintf("%s.0.%s", isVirtualEndpointGatewayTarget, isVirtualEndpointGatewayTargetCRN)
5354
return &schema.Resource{
54-
Create: resourceIBMisVirtualEndpointGatewayCreate,
55-
Read: resourceIBMisVirtualEndpointGatewayRead,
56-
Update: resourceIBMisVirtualEndpointGatewayUpdate,
57-
Delete: resourceIBMisVirtualEndpointGatewayDelete,
58-
Exists: resourceIBMisVirtualEndpointGatewayExists,
59-
Importer: &schema.ResourceImporter{},
55+
CreateContext: resourceIBMisVirtualEndpointGatewayCreate,
56+
ReadContext: resourceIBMisVirtualEndpointGatewayRead,
57+
UpdateContext: resourceIBMisVirtualEndpointGatewayUpdate,
58+
DeleteContext: resourceIBMisVirtualEndpointGatewayDelete,
59+
Exists: resourceIBMisVirtualEndpointGatewayExists,
60+
Importer: &schema.ResourceImporter{},
6061

6162
CustomizeDiff: customdiff.All(
6263
customdiff.Sequence(
@@ -308,10 +309,12 @@ func ResourceIBMISEndpointGatewayValidator() *validate.ResourceValidator {
308309
return &ibmEndpointGatewayResourceValidator
309310
}
310311

311-
func resourceIBMisVirtualEndpointGatewayCreate(d *schema.ResourceData, meta interface{}) error {
312+
func resourceIBMisVirtualEndpointGatewayCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
312313
sess, err := vpcClient(meta)
313314
if err != nil {
314-
return err
315+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "create", "initialize-client")
316+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
317+
return tfErr.GetDiag()
315318
}
316319

317320
name := d.Get(isVirtualEndpointGatewayName).(string)
@@ -377,8 +380,9 @@ func resourceIBMisVirtualEndpointGatewayCreate(d *schema.ResourceData, meta inte
377380
}
378381
endpointGateway, response, err := sess.CreateEndpointGateway(opt)
379382
if err != nil {
380-
log.Printf("Create Endpoint Gateway failed: %v", response)
381-
return fmt.Errorf("[ERROR] Create Endpoint Gateway failed %s\n%s", err, response)
383+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("[ERROR] Create Endpoint Gateway failed %s\n%s", err, response), "ibm_is_virtual_endpoint_gateway", "create")
384+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
385+
return tfErr.GetDiag()
382386
}
383387

384388
d.SetId(*endpointGateway.ID)
@@ -392,7 +396,9 @@ func resourceIBMisVirtualEndpointGatewayCreate(d *schema.ResourceData, meta inte
392396
endpointGateway, response, err := sess.GetEndpointGateway(opt)
393397
if err != nil {
394398
log.Printf("Get Endpoint Gateway failed: %v", response)
395-
return fmt.Errorf("[ERROR] Get Endpoint Gateway failed %s\n%s", err, response)
399+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("GetEndpointGateway failed: %s", err.Error()), "ibm_is_virtual_endpoint_gateway", "read")
400+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
401+
return tfErr.GetDiag()
396402
}
397403
if len(endpointGateway.LifecycleReasons) > 0 {
398404
if endpointGateway.LifecycleReasons[0].Code != nil && strings.Compare(*endpointGateway.LifecycleReasons[0].Code, "access_pending") == 0 {
@@ -401,10 +407,10 @@ func resourceIBMisVirtualEndpointGatewayCreate(d *schema.ResourceData, meta inte
401407
}
402408
}
403409
if !isAccessPending {
404-
return err
410+
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "create", "access-pending").GetDiag()
405411
}
406412
} else {
407-
return err
413+
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "create", "not-private-path-service-gateway").GetDiag()
408414
}
409415
}
410416

@@ -427,13 +433,15 @@ func resourceIBMisVirtualEndpointGatewayCreate(d *schema.ResourceData, meta inte
427433
}
428434
}
429435

430-
return resourceIBMisVirtualEndpointGatewayRead(d, meta)
436+
return resourceIBMisVirtualEndpointGatewayRead(context, d, meta)
431437
}
432438

433-
func resourceIBMisVirtualEndpointGatewayUpdate(d *schema.ResourceData, meta interface{}) error {
439+
func resourceIBMisVirtualEndpointGatewayUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
434440
sess, err := vpcClient(meta)
435441
if err != nil {
436-
return err
442+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "update", "initialize-client")
443+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
444+
return tfErr.GetDiag()
437445
}
438446

439447
// create option
@@ -451,7 +459,7 @@ func resourceIBMisVirtualEndpointGatewayUpdate(d *schema.ResourceData, meta inte
451459
_, response, err := sess.UpdateEndpointGateway(opt)
452460
if err != nil {
453461
log.Printf("Update Endpoint Gateway failed: %v", response)
454-
return fmt.Errorf("Update Endpoint Gateway failed : %s\n%s", err, response)
462+
return flex.TerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "update").GetDiag()
455463
}
456464
id := d.Id()
457465
var remove, add []string
@@ -468,11 +476,13 @@ func resourceIBMisVirtualEndpointGatewayUpdate(d *schema.ResourceData, meta inte
468476
createSecurityGroupTargetBindingOptions.ID = &id
469477
_, response, err := sess.CreateSecurityGroupTargetBinding(createSecurityGroupTargetBindingOptions)
470478
if err != nil {
471-
return fmt.Errorf("Error while creating Security Group Target Binding %s\n%s", err, response)
479+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("Error while creating Security Group Target Binding %s\n%s", err, response), "ibm_is_virtual_endpoint_gateway", "update")
480+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
481+
return tfErr.GetDiag()
472482
}
473483
_, err = isWaitForVirtualEndpointGatewayAvailable(sess, d.Id(), d.Timeout(schema.TimeoutUpdate))
474484
if err != nil {
475-
return err
485+
return flex.TerraformErrorf(err, fmt.Sprintf("isWaitForVirtualEndpointGatewayAvailable failed: %s", err.Error()), "ibm_is_virtual_endpoint_gateway", "update").GetDiag()
476486
}
477487
}
478488
}
@@ -487,16 +497,18 @@ func resourceIBMisVirtualEndpointGatewayUpdate(d *schema.ResourceData, meta inte
487497
if response != nil && response.StatusCode == 404 {
488498
continue
489499
}
490-
return fmt.Errorf("Error Getting Security Group Target for this endpoint gateway (%s): %s\n%s", sgId, err, response)
500+
return flex.TerraformErrorf(err, fmt.Sprintf("Error Getting Security Group Target for this endpoint gateway (%s): %s\n%s", sgId, err, response), "ibm_is_virtual_endpoint_gateway", "update").GetDiag()
501+
491502
}
492503
deleteSecurityGroupTargetBindingOptions := sess.NewDeleteSecurityGroupTargetBindingOptions(sgId, id)
493504
response, err = sess.DeleteSecurityGroupTargetBinding(deleteSecurityGroupTargetBindingOptions)
494505
if err != nil {
495-
return fmt.Errorf("Error Deleting Security Group Target for this endpoint gateway : %s\n%s", err, response)
506+
return flex.TerraformErrorf(err, fmt.Sprintf("Error Deleting Security Group Target for this endpoint gateway : %s\n%s", err, response), "ibm_is_virtual_endpoint_gateway", "update").GetDiag()
507+
496508
}
497509
_, err = isWaitForVirtualEndpointGatewayAvailable(sess, d.Id(), d.Timeout(schema.TimeoutUpdate))
498510
if err != nil {
499-
return err
511+
return flex.TerraformErrorf(err, fmt.Sprintf("isWaitForVirtualEndpointGatewayAvailable failed: %s", err.Error()), "ibm_is_virtual_endpoint_gateway", "update").GetDiag()
500512
}
501513
}
502514
}
@@ -506,14 +518,16 @@ func resourceIBMisVirtualEndpointGatewayUpdate(d *schema.ResourceData, meta inte
506518
opt := sess.NewGetEndpointGatewayOptions(d.Id())
507519
endpointGateway, response, err := sess.GetEndpointGateway(opt)
508520
if err != nil {
509-
return fmt.Errorf("[ERROR] Error getting VPE: %s\n%s", err, response)
521+
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("[ERROR] Error getting VPE: %s\n%s", err, response), "ibm_is_virtual_endpoint_gateway", "update", "get-vpe").GetDiag()
522+
510523
}
511524
if d.HasChange(isVirtualEndpointGatewayTags) {
512525
oldList, newList := d.GetChange(isVirtualEndpointGatewayTags)
513526
err := flex.UpdateGlobalTagsUsingCRN(oldList, newList, meta, *endpointGateway.CRN, "", isUserTagType)
514527
if err != nil {
515528
log.Printf(
516529
"Error on update of VPE (%s) tags: %s", d.Id(), err)
530+
517531
}
518532
}
519533

@@ -526,13 +540,15 @@ func resourceIBMisVirtualEndpointGatewayUpdate(d *schema.ResourceData, meta inte
526540
}
527541
}
528542
}
529-
return resourceIBMisVirtualEndpointGatewayRead(d, meta)
543+
return resourceIBMisVirtualEndpointGatewayRead(context, d, meta)
530544
}
531545

532-
func resourceIBMisVirtualEndpointGatewayRead(d *schema.ResourceData, meta interface{}) error {
546+
func resourceIBMisVirtualEndpointGatewayRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
533547
sess, err := vpcClient(meta)
534548
if err != nil {
535-
return err
549+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "read", "initialize-client")
550+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
551+
return tfErr.GetDiag()
536552
}
537553
// read option
538554
opt := sess.NewGetEndpointGatewayOptions(d.Id())
@@ -543,14 +559,14 @@ func resourceIBMisVirtualEndpointGatewayRead(d *schema.ResourceData, meta interf
543559
return nil
544560
}
545561
log.Printf("Get Endpoint Gateway failed: %v", response)
546-
return fmt.Errorf("[ERROR] Get Endpoint Gateway failed %s\n%s", err, response)
562+
return flex.TerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "read").GetDiag()
547563
}
548564
d.Set(isVirtualEndpointGatewayName, endpointGateway.Name)
549565
d.Set(isVirtualEndpointGatewayHealthState, endpointGateway.HealthState)
550566
d.Set(isVirtualEndpointGatewayCreatedAt, endpointGateway.CreatedAt.String())
551567
d.Set(isVirtualEndpointGatewayLifecycleState, endpointGateway.LifecycleState)
552568
if err := d.Set(isVirtualEndpointGatewayLifecycleReasons, resourceEGWFlattenLifecycleReasons(endpointGateway.LifecycleReasons)); err != nil {
553-
return fmt.Errorf("[ERROR] Error setting lifecycle_reasons: %s", err)
569+
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("[ERROR] Error setting lifecycle_reasons: %s", err), "ibm_is_virtual_endpoint_gateway", "read", "set-lifecycle-reasons").GetDiag()
554570
}
555571
d.Set(isVirtualEndpointGatewayAllowDnsResolutionBinding, endpointGateway.AllowDnsResolutionBinding)
556572
d.Set(isVirtualEndpointGatewayResourceType, endpointGateway.ResourceType)
@@ -644,21 +660,25 @@ func isVirtualEndpointGatewayRefreshFunc(sess *vpcv1.VpcV1, endPointGatewayId st
644660
}
645661
}
646662

647-
func resourceIBMisVirtualEndpointGatewayDelete(d *schema.ResourceData, meta interface{}) error {
663+
func resourceIBMisVirtualEndpointGatewayDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
648664
sess, err := vpcClient(meta)
649665
if err != nil {
650-
return err
666+
tfErr := flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "delete", "initialize-client")
667+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
668+
return tfErr.GetDiag()
651669
}
652670

653671
opt := sess.NewDeleteEndpointGatewayOptions(d.Id())
654672
response, err := sess.DeleteEndpointGateway(opt)
655673
if err != nil {
656674
log.Printf("Delete Endpoint Gateway failed: %v", response)
657-
return fmt.Errorf("Delete Endpoint Gateway failed : %s\n%s", err, response)
675+
return flex.DiscriminatedTerraformErrorf(err, err.Error(), "ibm_is_virtual_endpoint_gateway", "delete", "sep-id-parts").GetDiag()
658676
}
659677
_, err = isWaitForEGWDelete(sess, d, d.Id())
660678
if err != nil {
661-
return err
679+
tfErr := flex.TerraformErrorf(err, fmt.Sprintf("DeleteEndpointGateway failed: %s", err.Error()), "ibm_is_virtual_endpoint_gateway", "delete")
680+
log.Printf("[DEBUG]\n%s", tfErr.GetDebugMessage())
681+
return tfErr.GetDiag()
662682
}
663683
return nil
664684
}

0 commit comments

Comments
 (0)