Skip to content

Commit

Permalink
change transaction error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Oct 25, 2023
1 parent 38ba699 commit 9a7f364
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions database/redis/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ func getNotificationsInTxWithLimit(ctx context.Context, tx *redis.Tx, to int64,

response := tx.ZRangeByScore(ctx, notifierNotificationsKey, rng)
if response.Err() != nil {
if errors.Is(response.Err(), redis.TxFailedErr) {
return nil, &transactionError{}
}
return nil, fmt.Errorf("failed to ZRANGEBYSCORE: %w", response.Err())
}

Expand Down Expand Up @@ -379,9 +382,6 @@ func (connector *DbConnector) fetchNotificationsDo(to int64, limit *int64) ([]*m
err := c.Watch(ctx, func(tx *redis.Tx) error {
notifications, err := getNotificationsInTxWithLimit(ctx, tx, to, limit)
if err != nil {
if errors.Is(err, redis.TxFailedErr) {
return &transactionError{}
}
return fmt.Errorf("failed to get notifications with limit in transaction: %w", err)
}

Expand Down

0 comments on commit 9a7f364

Please sign in to comment.