CancelledError
定义于:packages/query-core/src/retryer.ts:120
当一次拉取被取消(例如通过 query.cancel())时,Retryer(并传递至 query.promise/mutation)抛出的错误。revert 在 true 为真时,指示调用方将查询状态恢复至拉取开始前的状态,而非向上传播该错误。silent 在 true 为真时,指示调用方抑制该错误,并改为以触发取消操作的拉取所对应的 Promise 进行解析。
示例
TypeScript
1query.cancel()2 3try {4 await query.promise5} catch (error) {6 if (error instanceof CancelledError) {7 // the fetch was cancelled, e.g. via `query.cancel()`8 }9}继承自
Error
构造函数
构造函数
TypeScript
1new CancelledError(options?: CancelOptions): CancelledError;定义于:packages/query-core/src/retryer.ts:123
参数
options?
返回值
CancelledError
覆盖
TypeScript
1Error.constructor属性
revert?
TypeScript
1optional revert?: boolean;定义于:packages/query-core/src/retryer.ts:121
silent?
TypeScript
1optional silent?: boolean;