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