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

StorageError.md

225 lines4.4 KB

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