Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SessionTx is hiding errors by returning rollback result #29

Closed
wants to merge 2 commits into from

Conversation

c2h5oh
Copy link
Contributor

@c2h5oh c2h5oh commented Dec 5, 2018

It should be returning the error that caused the rollback and only return rollback result if rollback fails

…error that caused the rollback.

Rollback error should only be returned if rollback fails
session.go Outdated
@@ -8,7 +8,7 @@ import (
"reflect"
"sync"

"upper.io/db.v3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goimports fixing things for me - fixed.

Copy link
Member

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion. LGTM otherwise

session.go Outdated
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return both errors here?

Suggested change
return rErr
return errors.Wrap(err, rErr.Error())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants