Add logs for func saveStruct.

This commit is contained in:
Владислав Весельский 2024-03-13 15:49:29 +03:00
parent 7c9d4c28dc
commit 19cbc17f35
1 changed files with 8 additions and 2 deletions

10
save.go
View File

@ -217,14 +217,20 @@ func saveStruct(
row, _ = dataItem.Addr().Interface().(meta.IMetaStruct)
}
if row == nil {
return errors.Errorf("Couldn't convert to IMetaStruct: %s", mType.Name())
err := errors.Errorf("Couldn't convert to IMetaStruct: %s", mType.Name())
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
return err
}
props := *row.CLASS_PROPS()
if ownerField, ok := props["owner"]; ok {
field := dataItem.FieldByName(strings.Title(ownerField))
if !field.IsValid() {
return errors.Errorf("Owner field \"%s\" is not found in struct \"%s\"", ownerField, mType.Name())
err := errors.Errorf("Owner field \"%s\" is not found in struct \"%s\"", ownerField, mType.Name())
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
return err
}
// enforcing ownerId