From afb9845d70188b6102146fcf0bde229376c30e1d Mon Sep 17 00:00:00 2001 From: Vladislav Veselskiy Date: Wed, 13 Mar 2024 15:54:10 +0300 Subject: [PATCH] Add logs for SaveRow. --- save.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/save.go b/save.go index e88fe34..c0053ad 100644 --- a/save.go +++ b/save.go @@ -49,6 +49,8 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { info, err := makeDataRowInfo(dataItem) if err != nil { + span.RecordError(err) + span.SetStatus(codes.Error, err.Error()) return err } @@ -77,7 +79,10 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { } 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 @@ -97,7 +102,11 @@ func SaveRow(ctx context.Context, db *db.DBC, dataItem meta.IMetaStruct) error { if len(sqlSmt) > 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()