Files
openclaw/src/agents/session-write-lock-error.ts
2026-05-01 21:47:00 +01:00

30 lines
914 B
TypeScript

const SESSION_WRITE_LOCK_TIMEOUT_CODE = "OPENCLAW_SESSION_WRITE_LOCK_TIMEOUT";
export class SessionWriteLockTimeoutError extends Error {
readonly code = SESSION_WRITE_LOCK_TIMEOUT_CODE;
readonly timeoutMs: number;
readonly owner: string;
readonly lockPath: string;
constructor(params: { timeoutMs: number; owner: string; lockPath: string }) {
super(
`session file locked (timeout ${params.timeoutMs}ms): ${params.owner} ${params.lockPath}`,
);
this.name = "SessionWriteLockTimeoutError";
this.timeoutMs = params.timeoutMs;
this.owner = params.owner;
this.lockPath = params.lockPath;
}
}
export function isSessionWriteLockTimeoutError(err: unknown): boolean {
return (
err instanceof SessionWriteLockTimeoutError ||
Boolean(
err &&
typeof err === "object" &&
(err as { code?: unknown }).code === SESSION_WRITE_LOCK_TIMEOUT_CODE,
)
);
}