{"record":{"id":"aa4db45e9d135d31","repo":"earendil-works/pi","slug":"message-result-error-message","errorCode":null,"errorMessage":"${message}: ${result.error.message}","messagePattern":"\\$\\{message\\}: \\$\\{result\\.error\\.message\\}","errorType":"error_code","errorClass":"SessionError","httpStatus":null,"severity":"error","filePath":"packages/session-backends/sqlite-node/src/sqlite/repo.ts","lineNumber":159,"sourceCode":"\n\tenqueue<T>(operation: () => Promise<T> | T): Promise<T> {\n\t\tconst result = this.tail.then(operation);\n\t\tthis.tail = result.then(\n\t\t\t() => undefined,\n\t\t\t() => undefined,\n\t\t);\n\t\treturn result;\n\t}\n\n\tasync drain(): Promise<void> {\n\t\tawait this.tail;\n\t}\n}\n\nfunction resultOrThrow<T>(result: Result<T, FileError>, message: string): T {\n\tif (!result.ok) {\n\t\tconst code = result.error.code === \"not_found\" ? \"not_found\" : \"storage\";\n\t\tthrow new SessionError(code, `${message}: ${result.error.message}`, result.error);\n\t}\n\treturn result.value;\n}\n\nfunction getParentPath(path: string): string {\n\tconst normalized = path.replace(/[\\\\/]+$/, \"\");\n\tconst lastSlash = Math.max(normalized.lastIndexOf(\"/\"), normalized.lastIndexOf(\"\\\\\"));\n\tif (lastSlash < 0) return \".\";\n\tif (lastSlash === 0) return normalized.slice(0, 1);\n\treturn normalized.slice(0, lastSlash);\n}\n\nfunction configureSqliteDatabase(db: SqliteDatabase): void {\n\tsql`PRAGMA journal_mode=WAL`.exec(db);\n\tsql`PRAGMA synchronous=FULL`.exec(db);\n\tsql`PRAGMA busy_timeout=5000`.exec(db);\n}\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/session-backends/sqlite-node/src/sqlite/repo.ts#L141-L177","documentation":"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.","triggerScenarios":"Thrown at packages/session-backends/sqlite-node/src/sqlite/repo.ts:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped SQLite error message for the underlying failure."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}