more descriptive error messages

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-12-13 19:08:09 +03:00
parent 33521493f4
commit 55ce153545

View File

@ -3,6 +3,7 @@ package consul
import (
"context"
"errors"
"fmt"
"github.com/hashicorp/consul/api"
"github.com/unistack-org/micro/v3/config"
@ -82,9 +83,9 @@ func (c *consulConfig) Init(opts ...config.Option) error {
func (c *consulConfig) Load(ctx context.Context) error {
pair, _, err := c.cli.KV().Get(c.path, nil)
if err != nil {
return err
return fmt.Errorf("consul path load error: %v", err)
} else if pair == nil {
return ErrPathNotExist
return fmt.Errorf("consul path not found %v", ErrPathNotExist)
}
return c.opts.Codec.Unmarshal(pair.Value, c.opts.Struct)