mirror of https://github.com/go-gorm/gorm.git
provide user with more descriptive error message
This commit is contained in:
parent
4c1a78bab7
commit
fc42a1bbf3
3
field.go
3
field.go
|
@ -3,6 +3,7 @@ package gorm
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ func (field *Field) Set(value interface{}) error {
|
||||||
if reflectValue.Type().ConvertibleTo(field.Field.Type()) {
|
if reflectValue.Type().ConvertibleTo(field.Field.Type()) {
|
||||||
field.Field.Set(reflectValue.Convert(field.Field.Type()))
|
field.Field.Set(reflectValue.Convert(field.Field.Type()))
|
||||||
} else {
|
} else {
|
||||||
return errors.New("could not convert argument")
|
return fmt.Errorf("could not convert argument of field %s from %s to %s", field.Name, reflectValue.Type(), field.Field.Type())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue