-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
…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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
return rErr | |
return errors.Wrap(err, rErr.Error()) |
It should be returning the error that caused the rollback and only return rollback result if rollback fails