Description
The current errorCodes.ts is ad hoc. Replace it with a typed taxonomy distinguishing public-facing error codes (stable contract) from internal-only ones, and route messages through i18n keys instead of literals.
Requirements and context
- Must be secure, tested, and documented
- Should be efficient and easy to review
- Relevant code:
src/errors/errorCodes.ts, src/errors/sendError.ts
- Public codes guaranteed to be stable across versions
Suggested execution
- Fork the repo and create a branch
git checkout -b refactor/error-taxonomy
- Implement changes
- Discriminated union of public/internal errors
- Codegen of doc table from taxonomy
- Type-safe
sendError accepting only known codes
- Validate security and correctness assumptions
Test and commit
- Run tests
- Cover edge cases
- Unknown code at compile-time is a type error
- Include test output and notes
Example commit message
refactor: typed error taxonomy with i18n keys
Guidelines
- Minimum 95 percent test coverage
- Clear documentation
- Timeframe: 96 hours
Description
The current
errorCodes.tsis ad hoc. Replace it with a typed taxonomy distinguishing public-facing error codes (stable contract) from internal-only ones, and route messages through i18n keys instead of literals.Requirements and context
src/errors/errorCodes.ts,src/errors/sendError.tsSuggested execution
git checkout -b refactor/error-taxonomysendErroraccepting only known codesTest and commit
npm testExample commit message
refactor: typed error taxonomy with i18n keysGuidelines