Is it possible to get the attempt number?
amaury1093 opened this issue · 3 comments
amaury1093 commented
In the example in the README, I would like to also log the attempt number, something like:
const logDelay = (delay: number, attempt: number) => TE.rightIO(log(`Attempt #${attempt} failed, retrying in ${delay} milliseconds`))
Right now, I'm setting a let attempt = 0;
outside of the retrying()
function, and doing a side effect to increment it on every retry. But maybe there's a cleaner way?
gcanti commented
you can leverage the iterNumber
field https://gcanti.github.io/retry-ts/modules/index.ts.html#retrystatus-interface
amaury1093 commented
Thanks, that works.
Follow-up question: how about if I want to show, on each retry, the error message returned by the previous (failed) attempt?
SRachamim commented
+1 for the follow-up question:
how about if I want to show, on each retry, the error message returned by the previous (failed) attempt?