Skip to content

refactor: domain error hierarchy (ROADMAP 3.8)#431

Merged
carlos-alm merged 5 commits intomainfrom
refactor/domain-error-hierarchy
Mar 13, 2026
Merged

refactor: domain error hierarchy (ROADMAP 3.8)#431
carlos-alm merged 5 commits intomainfrom
refactor/domain-error-hierarchy

Conversation

@carlos-alm
Copy link
Contributor

Summary

  • Add src/errors.js with structured domain error hierarchy: CodegraphError base class + 7 subclasses (ParseError, DbError, ConfigError, ResolutionError, EngineError, AnalysisError, BoundaryError)
  • Replace all process.exit(1) calls in library code (embedder, db/connection, watcher, mcp/server, snapshot) with thrown domain errors
  • Replace all throw new Error() in library code (ast-analysis/shared, batch, db/query-builder, db/repository/nodes, native, snapshot) with appropriate domain error subclasses
  • CLI top-level catch formats CodegraphError with [CODE]: message prefix; MCP catch returns structured { isError, code } responses
  • CI gate commands (check, manifesto) use process.exitCode = 1 instead of process.exit(1)
  • CLI uses parseAsync() so async command errors propagate to the top-level handler
  • All error classes exported from the public API (src/index.js)

Test plan

  • New tests/unit/errors.test.js — 16 tests covering all classes, instanceof chain, option forwarding
  • Updated tests/unit/db.test.js — asserts DbError instead of process.exit spy
  • Updated tests/unit/prompt-install.test.js — asserts EngineError instead of process.exit spy
  • All existing tests pass (97/97 in affected files)
  • Lint clean (biome check passes)
  • Zero process.exit(1) remaining in library code (only in CLI entry point)
  • Zero throw new Error remaining in src/

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant