Skip to content

Commit

Permalink
Merge pull request #31 from c2h5oh/txsession
Browse files Browse the repository at this point in the history
SessionTx is hiding errors by returning rollback result
  • Loading branch information
VojtechVitek committed Dec 5, 2018
2 parents 1c2483f + 54e47d9 commit 2702bd1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package bond
import (
"context"
"database/sql"
"errors"
"fmt"
"reflect"
"sync"

"github.com/pkg/errors"
"upper.io/db.v3"
"upper.io/db.v3/lib/sqlbuilder"
)
Expand Down 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 errors.Wrap(err, rErr.Error())
}
return err
}
return t.Commit()
}
Expand Down

0 comments on commit 2702bd1

Please sign in to comment.