Merge d3b49c3d235b670ba7fb2d5558dfa48033f7b9d8 into 4e34a6d21b63e9a9b701a70be9759e5539bf26e9
This commit is contained in:
commit
80c8015d23
@ -946,6 +946,22 @@ func (field *Field) setupValuerAndSetter(modelType reflect.Type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var oldSetter = field.Set
|
||||||
|
field.Set = func(ctx context.Context, value reflect.Value, v interface{}) (err error) {
|
||||||
|
err = oldSetter(ctx, value, v)
|
||||||
|
if err == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var errMessage = err.Error()
|
||||||
|
// It's ugly and unrobust, but it's required since the fallbackSetter create error by fmt.Errorf directly and here are some nested setter calls.
|
||||||
|
// Without string manipulation, there's no way to avoid a duplicated error message.
|
||||||
|
// Also, adding many fmt.Errorf calls in all setter implementations is not a good idea, apparently.
|
||||||
|
if strings.Contains(errMessage, "to field "+field.Name) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = fmt.Errorf("failed to set value to field %s: %w", field.Name, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if field.Serializer != nil {
|
if field.Serializer != nil {
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user