Merge pull request #750 from lcowell/better_field_error

provide user with more descriptive error message
This commit is contained in:
Jinzhu 2015-12-09 10:44:54 +08:00
commit 8ee49893d1
1 changed files with 2 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package gorm
import (
"database/sql"
"errors"
"fmt"
"reflect"
)
@ -44,7 +45,7 @@ func (field *Field) Set(value interface{}) error {
if reflectValue.Type().ConvertibleTo(field.Field.Type()) {
field.Field.Set(reflectValue.Convert(field.Field.Type()))
} 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())
}
}