earendil-works/pi · error · SessionError

${message}: ${result.error.message}

Error message

${message}: ${result.error.message}

What it means

Result-to-exception bridge in the SQLite session repository: a filesystem operation returned a failed Result (!result.ok), and it is converted to a SessionError whose code is 'not_found' when the underlying FileError was not_found, otherwise 'storage'. The contextual message prefixes the original error so callers see which repository operation (list, getDatabasePath, openDatabase) failed.

Solutions

  1. Inspect the wrapped SQLite error message for the underlying failure.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at packages/session-backends/sqlite-node/src/sqlite/repo.ts:159 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/aa4db45e9d135d31. Report an issue: GitHub.

Appendix: source

Thrown at packages/session-backends/sqlite-node/src/sqlite/repo.ts:159

	enqueue<T>(operation: () => Promise<T> | T): Promise<T> {
		const result = this.tail.then(operation);
		this.tail = result.then(
			() => undefined,
			() => undefined,
		);
		return result;
	}

	async drain(): Promise<void> {
		await this.tail;
	}
}

function resultOrThrow<T>(result: Result<T, FileError>, message: string): T {
	if (!result.ok) {
		const code = result.error.code === "not_found" ? "not_found" : "storage";
		throw new SessionError(code, `${message}: ${result.error.message}`, result.error);
	}
	return result.value;
}

function getParentPath(path: string): string {
	const normalized = path.replace(/[\\/]+$/, "");
	const lastSlash = Math.max(normalized.lastIndexOf("/"), normalized.lastIndexOf("\\"));
	if (lastSlash < 0) return ".";
	if (lastSlash === 0) return normalized.slice(0, 1);
	return normalized.slice(0, lastSlash);
}

function configureSqliteDatabase(db: SqliteDatabase): void {
	sql`PRAGMA journal_mode=WAL`.exec(db);
	sql`PRAGMA synchronous=FULL`.exec(db);
	sql`PRAGMA busy_timeout=5000`.exec(db);
}

View on GitHub (pinned to 4af9d21d3b)