You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The pipe never returns error within the TxPipelined function hence if i != 0 { block always gets run. All I see at the end is that, some general purpose error message. The code never gets to return res.Err() lines. How do we prevent progressing within TxPipelined function if any pipe command fails?
Last return err always returns some vague error and I cannot wrap any valuable info to it from any pipe errors as pipe res.Err() or .Result().Error() don't return error.
Thanks
returnr.Client.Watch(ctx, func(txn*redis.Tx) error {
_, err:=txn.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
variintfor_, item:=rangeitems {
ifres:=pipe.HSet(ctx, item.key, item.field, 0); res.Err() !=nil {
returnres.Err()
}
_=pipe.ExpireAt(ctx, key, item.expiry)
i++
}
ifi!=0 {
ifres:=pipe.HSet(ctx, "final", "count", i); res.Err() !=nil {
returnres.Err()
}
_=pipe.ExpireAt(ctx, "final", defaultExp)
}
returnnil
})
returnerr// This just returns a general level if a pipe fails
})
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
The
pipe
never returns error within theTxPipelined
function henceif i != 0 {
block always gets run. All I see at the end is that, some general purpose error message. The code never gets toreturn res.Err()
lines. How do we prevent progressing withinTxPipelined
function if any pipe command fails?Last
return err
always returns some vague error and I cannot wrap any valuable info to it from any pipe errors as piperes.Err()
or.Result().Error()
don't return error.Thanks
Beta Was this translation helpful? Give feedback.
All reactions