Open History to see the last commit
1---
2id: QueryCollectionError
3title: QueryCollectionError
4---
5
6Defined in: [packages/query-db-collection/src/errors.ts:4](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/errors.ts#L4)
7
8## Extends
9
10- `TanStackDBError`
11
12## Extended by
13
14- [`QueryKeyRequiredError`](QueryKeyRequiredError.md)
15- [`QueryFnRequiredError`](QueryFnRequiredError.md)
16- [`QueryClientRequiredError`](QueryClientRequiredError.md)
17- [`GetKeyRequiredError`](GetKeyRequiredError.md)
18- [`InitialDataInOnDemandModeError`](InitialDataInOnDemandModeError.md)
19- [`SyncNotInitializedError`](SyncNotInitializedError.md)
20- [`InvalidItemStructureError`](InvalidItemStructureError.md)
21- [`ItemNotFoundError`](ItemNotFoundError.md)
22- [`DuplicateKeyInBatchError`](DuplicateKeyInBatchError.md)
23- [`UpdateOperationItemNotFoundError`](UpdateOperationItemNotFoundError.md)
24- [`DeleteOperationItemNotFoundError`](DeleteOperationItemNotFoundError.md)
25- [`InvalidSyncOperationError`](InvalidSyncOperationError.md)
26- [`UnknownOperationTypeError`](UnknownOperationTypeError.md)
27- [`MissingKeyFieldError`](MissingKeyFieldError.md)
28
29## Constructors
30
31### Constructor
32
33```ts
34new QueryCollectionError(message): QueryCollectionError;
35```
36
37Defined in: [packages/query-db-collection/src/errors.ts:5](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/errors.ts#L5)
38
39#### Parameters
40
41##### message
42
43`string`
44
45#### Returns
46
47`QueryCollectionError`
48
49#### Overrides
50
51```ts
52TanStackDBError.constructor
53```
54
55## Properties
56
57### cause?
58
59```ts
60optional cause: unknown;
61```
62
63Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26
64
65#### Inherited from
66
67```ts
68TanStackDBError.cause
69```
70
71***
72
73### message
74
75```ts
76message: string;
77```
78
79Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077
80
81#### Inherited from
82
83```ts
84TanStackDBError.message
85```
86
87***
88
89### name
90
91```ts
92name: string;
93```
94
95Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076
96
97#### Inherited from
98
99```ts
100TanStackDBError.name
101```
102
103***
104
105### stack?
106
107```ts
108optional stack: string;
109```
110
111Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078
112
113#### Inherited from
114
115```ts
116TanStackDBError.stack
117```
118
119***
120
121### stackTraceLimit
122
123```ts
124static stackTraceLimit: number;
125```
126
127Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67
128
129The `Error.stackTraceLimit` property specifies the number of stack frames
130collected by a stack trace (whether generated by `new Error().stack` or
131`Error.captureStackTrace(obj)`).
132
133The default value is `10` but may be set to any valid JavaScript number. Changes
134will affect any stack trace captured _after_ the value has been changed.
135
136If set to a non-number value, or set to a negative number, stack traces will
137not capture any frames.
138
139#### Inherited from
140
141```ts
142TanStackDBError.stackTraceLimit
143```
144
145## Methods
146
147### captureStackTrace()
148
149```ts
150static captureStackTrace(targetObject, constructorOpt?): void;
151```
152
153Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51
154
155Creates a `.stack` property on `targetObject`, which when accessed returns
156a string representing the location in the code at which
157`Error.captureStackTrace()` was called.
158
159```js
160const myObject = {};
161Error.captureStackTrace(myObject);
162myObject.stack; // Similar to `new Error().stack`
163```
164
165The first line of the trace will be prefixed with
166`${myObject.name}: ${myObject.message}`.
167
168The optional `constructorOpt` argument accepts a function. If given, all frames
169above `constructorOpt`, including `constructorOpt`, will be omitted from the
170generated stack trace.
171
172The `constructorOpt` argument is useful for hiding implementation
173details of error generation from the user. For instance:
174
175```js
176function a() {
177 b();
178}
179
180function b() {
181 c();
182}
183
184function c() {
185 // Create an error without stack trace to avoid calculating the stack trace twice.
186 const { stackTraceLimit } = Error;
187 Error.stackTraceLimit = 0;
188 const error = new Error();
189 Error.stackTraceLimit = stackTraceLimit;
190
191 // Capture the stack trace above function b
192 Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
193 throw error;
194}
195
196a();
197```
198
199#### Parameters
200
201##### targetObject
202
203`object`
204
205##### constructorOpt?
206
207`Function`
208
209#### Returns
210
211`void`
212
213#### Inherited from
214
215```ts
216TanStackDBError.captureStackTrace
217```
218
219***
220
221### prepareStackTrace()
222
223```ts
224static prepareStackTrace(err, stackTraces): any;
225```
226
227Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55
228
229#### Parameters
230
231##### err
232
233`Error`
234
235##### stackTraces
236
237`CallSite`[]
238
239#### Returns
240
241`any`
242
243#### See
244
245https://v8.dev/docs/stack-trace-api#customizing-stack-traces
246
247#### Inherited from
248
249```ts
250TanStackDBError.prepareStackTrace
251```