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