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