katanakit-js / CancelledError
Class: CancelledError
Defined in: node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:1750
The error thrown by a Retryer (and surfaced to query.promise/mutation) when a fetch is cancelled, e.g. via query.cancel(). revert, if true, tells the caller to restore the state the query was in before the fetch started instead of surfacing the error. silent, if true, tells the caller to suppress this error and instead resolve with the promise of the fetch that triggered the cancellation.
Example
query.cancel()
try {
await query.promise
} catch (error) {
if (error instanceof CancelledError) {
// the fetch was cancelled, e.g. via `query.cancel()`
}
}Extends
Error
Constructors
Constructor
new CancelledError(options?): CancelledError;Defined in: node_modules/.bun/@tanstack+query-core@5.104.1/node_modules/@tanstack/query-core/build/modern/hydration-B9t5w6NC.d.ts:1753
Parameters
| Parameter | Type |
|---|---|
options? | CancelOptions |
Returns
CancelledError
Overrides
Error.constructorProperties
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@26.6.4/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns a string representing the location in the code at which Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with ${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames above constructorOpt, including constructorOpt, will be omitted from the generated stack trace.
The constructorOpt argument is useful for hiding implementation details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceCall Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.4.2/node_modules/bun-types/globals.d.ts:1081
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceisError()
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.4.2/node_modules/bun-types/globals.d.ts:1076
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Error.isErrorprepareStackTrace()
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@26.6.4/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace