UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.73 kB
import{i as extractErrorCode}from"./error-coercion-B-1Loz4b.mjs";import{l as resolveGlobalSingleton}from"./string-coerce-BBqv4GXj.mjs";import{t as isPromiseLike}from"./promise-like-OKzBwzLG.mjs"; //!src/infra/sqlite-lifecycle-errors.ts var SqliteSnapshotCleanupError=class extends Error{};var SqliteSnapshotDirectoryBusyError=class extends SqliteSnapshotCleanupError{constructor(...e){super(...e);this.name=`SqliteSnapshotDirectoryBusyError`}};function classifyRetiredSqliteSnapshotRemovalError(e,t){const n=extractErrorCode(t);if(t instanceof Error&&`syscall`in t&&(t.syscall===`rmdir`||t.syscall===`unlink`)&&(n===`EBUSY`||n===`ENOTEMPTY`))return new SqliteSnapshotDirectoryBusyError(`SQLite retired snapshot directory removal is busy: ${e}`,{cause:t});return t}var OpenClawStateOwnershipError=class extends Error{};var OpenClawStateOwnershipMetadataError=class extends OpenClawStateOwnershipError{constructor(e,t){super(`OpenClaw shared state ownership metadata is invalid at ${e}: ${t}. Repair it with OPENCLAW_SUPERVISOR_MODE=external openclaw database ownership claim --manager <manager-id>.`);this.databasePath=e;this.name=`OpenClawStateOwnershipMetadataError`}};var OpenClawStateExternalOwnershipError=class extends OpenClawStateOwnershipError{constructor(e,t){super(`OpenClaw shared state database ${e} is externally supervised by ${t}. Use that external supervisor with OPENCLAW_SUPERVISOR_MODE=external for writable operations.`);this.databasePath=e;this.managerId=t;this.name=`OpenClawStateExternalOwnershipError`}};const SqliteCoordinatorError=resolveGlobalSingleton(Symbol.for(`openclaw.sqliteCoordinatorError`),()=>class CoordinatorError extends Error{constructor(e,t){super(e);this.cause=t;this.name=`SqliteCoordinatorError`}});function createSqliteLifecycleAggregateError(e,t,n){return new AggregateError(e,t,{cause:n})}function throwSqliteLifecycleErrors(e,t){if(e.length===1)throw e[0];if(e.length>1)throw createSqliteLifecycleAggregateError(e,t,e[0])}function runWithSqliteCleanup(e,t,n){let r;try{r=n();if(isPromiseLike(r))throw new SqliteCoordinatorError(`${t} must remain synchronous`)}catch(n){try{e.release()}catch(e){throw createSqliteLifecycleAggregateError([n,e],`${t} and resource release both failed`,n)}throw n}try{e.release()}catch(e){throw new SqliteCoordinatorError(`${t} completed, but releasing its resource failed`,e)}return r}export{SqliteSnapshotCleanupError as a,createSqliteLifecycleAggregateError as c,SqliteCoordinatorError as i,runWithSqliteCleanup as l,OpenClawStateOwnershipError as n,SqliteSnapshotDirectoryBusyError as o,OpenClawStateOwnershipMetadataError as r,classifyRetiredSqliteSnapshotRemovalError as s,OpenClawStateExternalOwnershipError as t,throwSqliteLifecycleErrors as u};