Skip to content

[Improvement] Fix error handling gaps across the codebase #192

@d-oit

Description

@d-oit

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

  1. Use AppError class consistently with proper error codes
  2. Add user-facing error messages with recovery suggestions
  3. Distinguish "not found" from "error" in repository methods
  4. Add error boundary around AI Harness
  5. Add finally blocks for cleanup
  6. Close DB connection in CLI on exit

Acceptance Criteria

  • All catch blocks either rethrow or provide meaningful user feedback
  • AppError used consistently
  • Export panel shows error state with retry
  • CLI closes DB on exit
  • Connection pool validates new workers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions