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

TransactionError.md

230 lines5.0 KB

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