Skip to content

Commit

Permalink
add norm
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyKomarovCoder committed Nov 13, 2023
1 parent ed25963 commit 614a89f
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ func (r *transactionRep) CreateTransaction(ctx context.Context, transaction *mod
}
defer func() {
if err := tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
if err = tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
}

}
}()

Expand Down Expand Up @@ -197,9 +200,13 @@ func (r *transactionRep) UpdateTransaction(ctx context.Context, transaction *mod
if err != nil {
return fmt.Errorf("[repo] failed to start transaction: %w", err)
}

defer func() {
if err := tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
if err = tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
}

}
}()

Expand Down Expand Up @@ -291,9 +298,13 @@ func (r *transactionRep) DeleteTransaction(ctx context.Context, transactionID uu
if err != nil {
return fmt.Errorf("[repo] failed to start transaction: %w", err)
}

defer func() {
if err != nil {
tx.Rollback(ctx)
if err := tx.Rollback(ctx); err != nil {
if err = tx.Rollback(ctx); err != nil {
r.logger.Fatal("Rollback transaction Error: %w", err)
}

}
}()

Expand Down

0 comments on commit 614a89f

Please sign in to comment.