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