Description
Several critical error handling gaps exist:
Silently Swallowed Errors
| File |
Line |
Issue |
src/lib/search.ts |
546-548 |
progressiveSearch swallows "related" search errors silently (catch { // best-effort }) |
src/db/repository.ts |
641-643 |
upsertWebCache catches and logs but never throws — caller cannot detect failure |
src/db/repository.ts |
668-670 |
getWebCache catches and returns null — cannot distinguish "not found" from "error" |
src/lib/search.ts |
59-63 |
initEmbeddings catches errors silently, returns false — callers often do not check |
src/db/client.ts |
38-50 |
getSchema silently returns empty string on failure — DB could init without schema |
src/lib/llm/config.ts |
29-32 |
loadConfig silently falls back on localStorage parse errors — could mask corruption |
Missing Error Handling
| File |
Issue |
src/features/ai/AIHarness.tsx:40-131 |
handleSend is async but called from onKeyPress without error boundary |
src/features/editor/Editor.tsx:103-192 |
handleSave catches but shows only generic "Save failed" — no detail |
src/features/export/ExportPanel.tsx |
No error recovery UI — if export fails, user sees nothing |
src/app/App.tsx:142 |
Error screen shows raw error string without sanitization |
cli/index.ts:63 |
fs.readdirSync(source) — no try/catch around synchronous FS operations |
cli/index.ts (end) |
No closeDb() call — potential resource leak |
Connection Pool
| File |
Issue |
src/db/connection-pool.ts:161-177 |
Worker timeout creates new worker but does not verify it is functional before resolving |
Recommended Fix
- Use
AppError class consistently with proper error codes
- Add user-facing error messages with recovery suggestions
- Distinguish "not found" from "error" in repository methods
- Add error boundary around AI Harness
- Add
finally blocks for cleanup
- Close DB connection in CLI on exit
Acceptance Criteria
Description
Several critical error handling gaps exist:
Silently Swallowed Errors
src/lib/search.tsprogressiveSearchswallows "related" search errors silently (catch { // best-effort })src/db/repository.tsupsertWebCachecatches and logs but never throws — caller cannot detect failuresrc/db/repository.tsgetWebCachecatches and returnsnull— cannot distinguish "not found" from "error"src/lib/search.tsinitEmbeddingscatches errors silently, returnsfalse— callers often do not checksrc/db/client.tsgetSchemasilently returns empty string on failure — DB could init without schemasrc/lib/llm/config.tsloadConfigsilently falls back on localStorage parse errors — could mask corruptionMissing Error Handling
src/features/ai/AIHarness.tsx:40-131handleSendis async but called fromonKeyPresswithout error boundarysrc/features/editor/Editor.tsx:103-192handleSavecatches but shows only generic "Save failed" — no detailsrc/features/export/ExportPanel.tsxsrc/app/App.tsx:142cli/index.ts:63fs.readdirSync(source)— no try/catch around synchronous FS operationscli/index.ts(end)closeDb()call — potential resource leakConnection Pool
src/db/connection-pool.ts:161-177Recommended Fix
AppErrorclass consistently with proper error codesfinallyblocks for cleanupAcceptance Criteria
catchblocks either rethrow or provide meaningful user feedbackAppErrorused consistently