Skip to content
Snippets Groups Projects

Don't return error if record not found in DB

3 files
+ 11
3
Compare changes
  • Side-by-side
  • Inline

Files

+ 7
1
@@ -11,6 +11,7 @@ package notifications
@@ -11,6 +11,7 @@ package notifications
import (
import (
"encoding/base64"
"encoding/base64"
"gitlab.com/elixxir/notifications-bot/notifications/apns"
"gitlab.com/elixxir/notifications-bot/notifications/apns"
 
"gorm.io/gorm"
"sync"
"sync"
"github.com/pkg/errors"
"github.com/pkg/errors"
@@ -350,7 +351,12 @@ func (nb *Impl) UnregisterForNotifications(request *pb.NotificationUnregisterReq
@@ -350,7 +351,12 @@ func (nb *Impl) UnregisterForNotifications(request *pb.NotificationUnregisterReq
}
}
err = nb.Storage.DeleteUserByHash(u.TransmissionRSAHash)
err = nb.Storage.DeleteUserByHash(u.TransmissionRSAHash)
if err != nil {
if err != nil {
return errors.Wrap(err, "Failed to unregister user with notifications")
if errors.Is(err, gorm.ErrRecordNotFound) {
 
jww.WARN.Println(err)
 
return nil
 
} else {
 
return errors.Wrap(err, "Failed to unregister user with notifications")
 
}
}
}
return nil
return nil
}
}
Loading