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

TransactionError.md

232 lines5.0 KB

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