Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

InvalidKeyError.md

222 lines4.5 KB

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