Consumer-invisible modernization pass — no public API or runtime-behavior
change; dist for the override-only files is byte-identical.
Toolchain:
- CI: GitHub Actions matrix — Node 22/24 (test:unit) + Bun latest (test:bun).
- engines: node ">=22" (was "22.x"), bun ">=1.1.0".
- tsconfig: isolatedModules + noImplicitOverride; add the 33 `override`
modifiers the flag requires across storage/integrations/vfs/transaction.
- deps: @types/node ^22; add prettier; drop dead standard-version,
@rollup/plugin-* and the redundant embedded eslintConfig (flat
eslint.config.js is the active config — verified identical lint output).
paramValidation: replace the top-level `await import('node:os'/'node:fs')`
with static ESM imports. The top-level-await form poisoned the module graph;
static imports also drop the browser/edge fallback branches no supported
runtime reaches (8.0 is Node/Bun/Deno-only).
Bun positioning: recommend Bun as a runtime (`bun add` / `bun run`), which is
green (test:bun 8/8). Drop single-binary `bun build --compile` as a target —
native addons cannot embed into it, and Bun 1.3.10 has a `--compile` codegen
regression around top-level await. Rename the Bun test to bun-runtime-test.ts
and correct docs that overclaimed single-binary support.
Gates: typecheck 0, build 0, test:unit 1743/1743, test:bun 8/8.
88 lines
2 KiB
TypeScript
88 lines
2 KiB
TypeScript
/**
|
|
* Transaction System Errors
|
|
*
|
|
* Provides detailed error information for transaction failures.
|
|
*/
|
|
|
|
/**
|
|
* Base class for all transaction errors
|
|
*/
|
|
export class TransactionError extends Error {
|
|
constructor(
|
|
message: string,
|
|
public readonly context?: Record<string, any>
|
|
) {
|
|
super(message)
|
|
this.name = 'TransactionError'
|
|
Error.captureStackTrace(this, this.constructor)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Error during transaction execution
|
|
*/
|
|
export class TransactionExecutionError extends TransactionError {
|
|
constructor(
|
|
message: string,
|
|
public readonly operationIndex: number,
|
|
public readonly operationName: string | undefined,
|
|
public override readonly cause: Error
|
|
) {
|
|
super(message, {
|
|
operationIndex,
|
|
operationName,
|
|
cause: cause.message
|
|
})
|
|
this.name = 'TransactionExecutionError'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Error during transaction rollback
|
|
*/
|
|
export class TransactionRollbackError extends TransactionError {
|
|
constructor(
|
|
message: string,
|
|
public readonly originalError: Error,
|
|
public readonly rollbackErrors: Error[]
|
|
) {
|
|
super(message, {
|
|
originalError: originalError.message,
|
|
rollbackErrorCount: rollbackErrors.length,
|
|
rollbackErrors: rollbackErrors.map(e => e.message)
|
|
})
|
|
this.name = 'TransactionRollbackError'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Error for invalid transaction state
|
|
*/
|
|
export class InvalidTransactionStateError extends TransactionError {
|
|
constructor(
|
|
currentState: string,
|
|
attemptedAction: string
|
|
) {
|
|
super(
|
|
`Cannot ${attemptedAction}: transaction is in state '${currentState}'`,
|
|
{ currentState, attemptedAction }
|
|
)
|
|
this.name = 'InvalidTransactionStateError'
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Error for transaction timeout
|
|
*/
|
|
export class TransactionTimeoutError extends TransactionError {
|
|
constructor(
|
|
timeoutMs: number,
|
|
operationIndex: number
|
|
) {
|
|
super(
|
|
`Transaction timed out after ${timeoutMs}ms at operation ${operationIndex}`,
|
|
{ timeoutMs, operationIndex }
|
|
)
|
|
this.name = 'TransactionTimeoutError'
|
|
}
|
|
}
|