Prevent failed SaveNotification transaction from locking the database

This commit is contained in:
Alessio 2024-09-14 16:01:28 -07:00
parent b9e025589e
commit 2731d787c2

View File

@ -9,6 +9,13 @@ import (
func (p Profile) SaveNotification(n Notification) { func (p Profile) SaveNotification(n Notification) {
tx, err := p.DB.Beginx() tx, err := p.DB.Beginx()
defer func() {
if r := recover(); r != nil {
tx.Rollback()
panic(r) // Re-raise the panic
}
}()
if err != nil { if err != nil {
panic(err) panic(err)
} }