Skip to content

Commit

Permalink
SessionTx shouldn't return rollback error/success - it should return …
Browse files Browse the repository at this point in the history
…error that caused the rollback.

Rollback error should only be returned if rollback fails
  • Loading branch information
c2h5oh committed Dec 5, 2018
1 parent 07a85c1 commit 21d5ad8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ func (s *session) SessionTx(ctx context.Context, fn func(sess Session) error) er
defer t.Close()
err := txFn(t)
if err != nil {
return t.Rollback()
if rErr := t.Rollback(); rErr != nil {
return rErr
}
return err
}
return t.Commit()
}
Expand Down

0 comments on commit 21d5ad8

Please sign in to comment.