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

GetKeyRequiredError.md

230 lines3.8 KB

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