Add logs for SaveRow.

This commit is contained in:
Владислав Весельский 2024-03-13 15:54:10 +03:00
parent 19cbc17f35
commit afb9845d70
1 changed files with 11 additions and 2 deletions

13
save.go
View File

@ -49,6 +49,8 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error {
info, err := makeDataRowInfo(dataItem) info, err := makeDataRowInfo(dataItem)
if err != nil { if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
return err return err
} }
@ -77,7 +79,10 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error {
} }
if len(fields) == 0 { if len(fields) == 0 {
return errors.New("Fields list is empty") err := errors.New("Fields list is empty")
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
return err
} }
tableName := info.tableName tableName := info.tableName
@ -97,7 +102,11 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error {
if len(sqlSmt) > 200 { if len(sqlSmt) > 200 {
sqlSmt = sqlSmt[0:200] sqlSmt = sqlSmt[0:200]
} }
return errors.Errorf("Can not execute SaveRow. Got error from updateBuilder.ExecContext. %s (%s)", err.Error(), sqlSmt)
resultErr := errors.Errorf("Can not execute SaveRow. Got error from updateBuilder.ExecContext. %s (%s)", err.Error(), sqlSmt)
span.RecordError(resultErr)
span.SetStatus(codes.Error, resultErr.Error())
return resultErr
} }
insertId, _ := res.LastInsertId() insertId, _ := res.LastInsertId()