iterx: Improve error messages

This commit is contained in:
Michał Matczuk
2020-01-17 13:01:07 +01:00
committed by Michal Jan Matczuk
parent 4b8b455fa0
commit 2c5ac087ec

View File

@@ -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
}