From 2c5ac087ec5e1aa725580b44a93e11206ade141d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Matczuk?= Date: Fri, 17 Jan 2020 13:01:07 +0100 Subject: [PATCH] iterx: Improve error messages --- iterx.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iterx.go b/iterx.go index c419549..74d0287 100644 --- a/iterx.go +++ b/iterx.go @@ -76,11 +76,11 @@ func (iter *Iterx) Get(dest interface{}) error { func (iter *Iterx) scanAny(dest interface{}, structOnly bool) bool { value := reflect.ValueOf(dest) if value.Kind() != reflect.Ptr { - iter.err = errors.New("must pass a pointer, not a value, to StructScan destination") + iter.err = fmt.Errorf("expected a pointer but got %T", dest) return false } if value.IsNil() { - iter.err = errors.New("nil pointer passed to StructScan destination") + iter.err = errors.New("expected a pointer but got nil") return false } @@ -123,11 +123,11 @@ func (iter *Iterx) scanAll(dest interface{}, structOnly bool) bool { // json.Unmarshal returns errors for these if value.Kind() != reflect.Ptr { - iter.err = errors.New("must pass a pointer, not a value, to StructScan destination") + iter.err = fmt.Errorf("expected a pointer but got %T", dest) return false } if value.IsNil() { - iter.err = errors.New("nil pointer passed to StructScan destination") + iter.err = errors.New("expected a pointer but got nil") return false }