From e0ccfb90e77fd8691bd9c165c926c50f79e737d3 Mon Sep 17 00:00:00 2001 From: Harshil Sharma Date: Fri, 9 Jul 2021 09:11:54 +0530 Subject: [PATCH] Fixed missing errors (#694) --- server/services/store/sqlstore/blocks.go | 20 ++++++++++++++++---- server/services/store/storetests/helpers.go | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/services/store/sqlstore/blocks.go b/server/services/store/sqlstore/blocks.go index d4e49a356..9e311e197 100644 --- a/server/services/store/sqlstore/blocks.go +++ b/server/services/store/sqlstore/blocks.go @@ -427,7 +427,10 @@ func (s *SQLStore) InsertBlock(c store.Container, block *model.Block, userID str query := insertQuery.SetMap(insertQueryValues) _, err = sq.ExecContextWith(ctx, tx, query.Into(s.tablePrefix+"blocks")) if err != nil { - tx.Rollback() + if rollbackErr := tx.Rollback(); rollbackErr != nil { + s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr)) + } + return err } } @@ -437,7 +440,9 @@ func (s *SQLStore) InsertBlock(c store.Container, block *model.Block, userID str _, err = sq.ExecContextWith(ctx, tx, query.Into(s.tablePrefix+"blocks_history")) if err != nil { - _ = tx.Rollback() + if rollbackErr := tx.Rollback(); rollbackErr != nil { + s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr)) + } return err } @@ -475,7 +480,9 @@ func (s *SQLStore) DeleteBlock(c store.Container, blockID string, modifiedBy str _, err = sq.ExecContextWith(ctx, tx, insertQuery) if err != nil { - _ = tx.Rollback() + if rollbackErr := tx.Rollback(); rollbackErr != nil { + s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr)) + } return err } @@ -486,7 +493,9 @@ func (s *SQLStore) DeleteBlock(c store.Container, blockID string, modifiedBy str _, err = sq.ExecContextWith(ctx, tx, deleteQuery) if err != nil { - _ = tx.Rollback() + if rollbackErr := tx.Rollback(); rollbackErr != nil { + s.logger.Warn("Transaction rollback error", mlog.Err(rollbackErr)) + } return err } @@ -558,6 +567,9 @@ func (s *SQLStore) GetBlock(c store.Container, blockID string) (*model.Block, er } blocks, err := s.blocksFromRows(rows) + if err != nil { + return nil, err + } if len(blocks) == 0 { return nil, nil diff --git a/server/services/store/storetests/helpers.go b/server/services/store/storetests/helpers.go index 20dd81dd3..371ec036f 100644 --- a/server/services/store/storetests/helpers.go +++ b/server/services/store/storetests/helpers.go @@ -9,8 +9,8 @@ import ( ) func InsertBlocks(t *testing.T, s store.Store, container store.Container, blocks []model.Block, userID string) { - for _, block := range blocks { - err := s.InsertBlock(container, &block, userID) + for i := range blocks { + err := s.InsertBlock(container, &blocks[i], userID) require.NoError(t, err) } }