Skip to content

Commit

Permalink
catch transaction error
Browse files Browse the repository at this point in the history
  • Loading branch information
fizzday committed Apr 7, 2024
1 parent 583698b commit e8f4f4c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion database.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,11 @@ func (db *Database) Transaction(closure ...func(TxHandler) error) (err error) {
for _, v := range closure {
err = v(tx)
if err != nil {
return db.Rollback()
err2 := db.Rollback()
if err2 != nil {
return err2
}
return err
}
}
return db.Commit()
Expand Down

0 comments on commit e8f4f4c

Please sign in to comment.