lang: types: Improve error handling of value code

We can give a bit more feedback and try and also catch a rare scenario.
This commit is contained in:
James Shubin
2023-11-12 15:24:16 -05:00
parent cb999af653
commit efc5237265

View File

@@ -233,7 +233,7 @@ func ValueOf(v reflect.Value) (Value, error) {
}, nil
default:
return nil, fmt.Errorf("unable to represent value of %+v", v)
return nil, fmt.Errorf("unable to represent value of %+v which has kind: %v", v, kind)
}
}
@@ -280,6 +280,10 @@ func Into(v Value, rv reflect.Value) error {
return fmt.Errorf("cannot Into() %+v of type %s into %s", v, v.Type(), typ)
}
if typ == nil {
return fmt.Errorf("cannot Into() %+v of type %s into a nil type", v, v.Type())
}
switch v := v.(type) {
case *BoolValue:
if err := mustInto(reflect.Bool); err != nil {