iterx: Improve error messages
This commit is contained in:
committed by
Michal Jan Matczuk
parent
4b8b455fa0
commit
2c5ac087ec
8
iterx.go
8
iterx.go
@@ -76,11 +76,11 @@ func (iter *Iterx) Get(dest interface{}) error {
|
|||||||
func (iter *Iterx) scanAny(dest interface{}, structOnly bool) bool {
|
func (iter *Iterx) scanAny(dest interface{}, structOnly bool) bool {
|
||||||
value := reflect.ValueOf(dest)
|
value := reflect.ValueOf(dest)
|
||||||
if value.Kind() != reflect.Ptr {
|
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
|
return false
|
||||||
}
|
}
|
||||||
if value.IsNil() {
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,11 +123,11 @@ func (iter *Iterx) scanAll(dest interface{}, structOnly bool) bool {
|
|||||||
|
|
||||||
// json.Unmarshal returns errors for these
|
// json.Unmarshal returns errors for these
|
||||||
if value.Kind() != reflect.Ptr {
|
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
|
return false
|
||||||
}
|
}
|
||||||
if value.IsNil() {
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user