【发布时间】:2022-06-30 06:00:39
【问题描述】:
我在我的 Vue 3 / TypeScript 项目中使用 Vue Concurrency。
我想创建一个任务,如果抛出特定类型的错误,它将重试x 次。
但我不知道如何根据错误消息重试调用。如果错误是INVALID_OAUTH,我想重试几次。否则像平常一样抛出错误。
如何做到这一点?
例如:
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');
【问题讨论】:
标签: typescript vue.js