diff --git a/reflect/error.go b/reflect/error.go index ed6199a7b..c4a369c25 100644 --- a/reflect/error.go +++ b/reflect/error.go @@ -5,21 +5,21 @@ import ( "fmt" ) -// FieldNotKnown report field not found. -type FieldNotKnown struct { +// FieldNotValid report field not valid. +type FieldNotValid struct { Kind string Name string } -func (e *FieldNotKnown) Error() string { +func (e *FieldNotValid) Error() string { return fmt.Sprintf( - "(%s) '%s' not known.", + "(%s) '%s' not valid.", e.Kind, e.Name) } -func (e *FieldNotKnown) Is(err error) (matched bool) { - var inst *FieldNotKnown +func (e *FieldNotValid) Is(err error) (matched bool) { + var inst *FieldNotValid matched = errors.As(err, &inst) return } diff --git a/reflect/fields.go b/reflect/fields.go index e73c229b2..73e593c2f 100644 --- a/reflect/fields.go +++ b/reflect/fields.go @@ -127,7 +127,7 @@ func HasFields(m any, in ...string) (out []string, err error) { for _, name := range in { _, found := mp[name] if !found { - err = &FieldNotKnown{ + err = &FieldNotValid{ Kind: NameOf(m), Name: name, }