How to retry Tasks?
BenJackGill opened this issue · comments
BenJackGill commented
I want to create a Task that will retry x
number of times if a specific kind of error is thrown.
But I can't figure out how to retry the call based on it's error message. I want to retry the call a limited number of times if the error is INVALID_OAUTH
. Otherwise just throw the error like normal.
Do you have any examples I can use as inspiration?
My stupid brain can't figure it out.
For example:
const getZohoDeskTicketByIdTask = useTask(function* (signal, ticketId: string) {
const ticket: string = yield getZohoDeskTicketById({
ticketId: ticketId,
});
// If the above yield returns an error of 'INVALID_OAUTH' it should retry X number of times before failing. If the error is anything else, throw it like normal.
return ticket;
});
const ticket = await getZohoDeskTicketByIdTask.perform('12345');
BenJackGill commented
Please disgrard. I took another route.
I tried to delete this issue but I couldn't. Feel free to delete it if you can.