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

Commit

Permalink
Improve Error traces (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksymAtVgs authored Dec 7, 2021
1 parent dde36f8 commit b810674
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions provider/type_resource_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package provider
import (
"context"
"fmt"
"regexp"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/pkg/errors"
vgs "github.com/verygoodsecurity/vgs-api-client-go/clients"
vgstools "github.com/verygoodsecurity/vgs-api-client-go/tools"
"regexp"
"strings"
)

const (
Expand Down Expand Up @@ -82,12 +83,12 @@ func createRoute(ctx context.Context, d *schema.ResourceData, m interface{}) dia
cfg := config(d)
c := m.(vgs.VgsClientsFacade)
if _, err := c.Vaults(cfg).RetrieveVault(vaultId); err != nil {
return diag.FromErr(err)
return diag.FromErr(errors.Wrap(err, "Failed to retrieve vault"))
}
routeYaml := d.Get("inline_config").(string)
routeId, err := c.Routes(cfg).ImportRoute(vaultId, strings.NewReader(routeYaml))
if err != nil {
return diag.FromErr(err)
return diag.FromErr(errors.Wrap(err, "Failed to import route"))
}
d.SetId(routeId)
return nil
Expand Down

0 comments on commit b810674

Please sign in to comment.