Compare commits

..

2 Commits

Author SHA1 Message Date
fcfa2f31d8 display path on error
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-29 11:14:21 +03:00
461d038f01 display path on error
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-07-29 11:13:26 +03:00

View File

@@ -2,7 +2,6 @@ package consul
import (
"context"
"errors"
"fmt"
"github.com/hashicorp/consul/api"
@@ -13,7 +12,6 @@ import (
var (
DefaultStructTag = "consul"
ErrPathNotExist = errors.New("path is not exist")
)
type consulConfig struct {
@@ -91,9 +89,9 @@ func (c *consulConfig) Load(ctx context.Context, opts ...config.LoadOption) erro
pair, _, err := c.cli.KV().Get(c.path, nil)
if err != nil && !c.opts.AllowFail {
return fmt.Errorf("consul path load error: %v", err)
return fmt.Errorf("consul path %s load error: %v", c.path, err)
} else if pair == nil && !c.opts.AllowFail {
return fmt.Errorf("consul path not found %v", ErrPathNotExist)
return fmt.Errorf("consul path %s not found", c.path)
}
if err == nil && pair != nil {
@@ -142,7 +140,7 @@ func (c *consulConfig) Save(ctx context.Context, opts ...config.SaveOption) erro
}
if err != nil && !c.opts.AllowFail {
return fmt.Errorf("consul path save error: %v", err)
return fmt.Errorf("consul path %s save error: %v", c.path, err)
}
for _, fn := range c.opts.AfterSave {