Skip to content

Commit

Permalink
Improve error message of associations.ForStruct
Browse files Browse the repository at this point in the history
Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com>
  • Loading branch information
aeneasr committed Dec 9, 2021
1 parent ff8d5e4 commit c47e802
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions associations/associations_for_struct.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package associations

import (
"errors"
"fmt"
"reflect"
"regexp"
Expand Down Expand Up @@ -30,7 +29,7 @@ var associationBuilders = map[string]associationBuilder{}
func ForStruct(s interface{}, fields ...string) (Associations, error) {
t, v := getModelDefinition(s)
if t.Kind() != reflect.Struct {
return nil, errors.New("could not get struct associations: not a struct")
return nil, fmt.Errorf("could not get struct associations: not a struct but %T", s)
}
fields = trimFields(fields)
associations := Associations{}
Expand Down

0 comments on commit c47e802

Please sign in to comment.