Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

CancelledError.md

77 lines1.6 KB

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 }
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)