From 2f287b4b80144205f9a5ea59962d75c84dcca918 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 29 Jul 2021 11:16:48 +0300 Subject: [PATCH] display path on error Signed-off-by: Vasiliy Tolstov --- vault.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vault.go b/vault.go index 762c92b..1edcef9 100644 --- a/vault.go +++ b/vault.go @@ -3,7 +3,7 @@ package vault import ( "context" "encoding/json" - "errors" + "fmt" "time" "github.com/hashicorp/vault/api" @@ -14,7 +14,6 @@ import ( var ( DefaultStructTag = "vault" - ErrPathNotExist = errors.New("path is not exist") ) type vaultConfig struct { @@ -109,7 +108,7 @@ func (c *vaultConfig) Load(ctx context.Context, opts ...config.LoadOption) error } if c.cli == nil && !c.opts.AllowFail { - return ErrPathNotExist + return fmt.Errorf("vault client not created") } else if c.cli == nil && c.opts.AllowFail { return nil } @@ -118,7 +117,7 @@ func (c *vaultConfig) Load(ctx context.Context, opts ...config.LoadOption) error if err != nil && !c.opts.AllowFail { return err } else if (pair == nil || pair.Data == nil) && !c.opts.AllowFail { - return ErrPathNotExist + return fmt.Errorf("vault path %s not found", c.path) } if err == nil && pair != nil && pair.Data != nil {