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