~ashkeel/kilovolt-client-go

982fcb59a94474ac780d01e865ffcd2602afa789 — Ash Keel 3 years ago d586707 v1.1.0
Add catchable error for unset/empty keys
1 files changed, 5 insertions(+), 0 deletions(-)

M client.go
M client.go => client.go +5 -0
@@ 19,6 19,7 @@ import (
var (
	ErrNotAuthenticated     = errors.New("not authenticated")
	ErrSubscriptionNotFound = errors.New("subscription not found")
	ErrEmptyKey             = errors.New("key empty or unset")
)

type Client struct {


@@ 162,6 163,10 @@ func (s *Client) GetJSON(key string, dst interface{}) error {
		return err
	}

	if resp.Data == nil || resp.Data.(string) == "" {
		return ErrEmptyKey
	}

	return jsoniter.ConfigFastest.UnmarshalFromString(resp.Data.(string), dst)
}