chai icon indicating copy to clipboard operation
chai copied to clipboard

StructScan panics when the interface parameter is not a struct

Open tzzed opened this issue 2 years ago • 0 comments

What version of Genji are you using?

$ genji version
Genji (devel)
Genji CLI (devel)

What did you do?

StructScan panics when the api contract is not respected, it will be very good an error is returned instead of panic.

        var b int
	d := document.NewFieldBuffer().Add("a", types.NewIntegerValue(10))
        err := document.StructScan(d, &b)
	assert.Error(t, err)

What did you expect to see?

An error message.

target must be pointer to struct

What did you see instead?

panic: reflect: call of reflect.Value.NumField on int Value [recovered]
	panic: reflect: call of reflect.Value.NumField on int Value

tzzed avatar Mar 10 '22 14:03 tzzed