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:
@@ -233,7 +233,7 @@ func ValueOf(v reflect.Value) (Value, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
default:
|
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)
|
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) {
|
switch v := v.(type) {
|
||||||
case *BoolValue:
|
case *BoolValue:
|
||||||
if err := mustInto(reflect.Bool); err != nil {
|
if err := mustInto(reflect.Bool); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user