Open History to see the last commit
1---
2id: CancelledError
3title: CancelledError
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8Defined in: [packages/query-core/src/retryer.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L120)
9β
10The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via
11`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch
12started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead
13resolve with the promise of the fetch that triggered the cancellation.
14β
15## Example
16β
17```ts
18query.cancel()
19β
20try {
21 await query.promise
22} catch (error) {
23 if (error instanceof CancelledError) {
24 // the fetch was cancelled, e.g. via `query.cancel()`
25 }
26}
27```
28β
29## Extends
30β
31- `Error`
32β
33## Constructors
34β
35### Constructor
36β
37```ts
38new CancelledError(options?: CancelOptions): CancelledError;
39```
40β
41Defined in: [packages/query-core/src/retryer.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L123)
42β
43#### Parameters
44β
45##### options?
46β
47[`CancelOptions`](../interfaces/CancelOptions.md)
48β
49#### Returns
50β
51`CancelledError`
52β
53#### Overrides
54β
55```ts
56Error.constructor
57```
58β
59## Properties
60β
61### revert?
62β
63```ts
64optional revert?: boolean;
65```
66β
67Defined in: [packages/query-core/src/retryer.ts:121](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L121)
68β
69***
70β
71### silent?
72β
73```ts
74optional silent?: boolean;
75```
76β
77Defined in: [packages/query-core/src/retryer.ts:122](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L122)