refactor(errors): split error-registry into per-category modules (#1989) - #2051
Merged
Conversation
The 842-line error-registry.ts was a single edit hotspot for all 81 error definitions across 11 categories — merge contention and hard-to-see category boundaries (audit #1989, finding #7). Move each category's defineError consts into src/errors/error-registry/<category>.ts (config, build, runtime, route, module, server, boundary, dev, deploy, agent, general), each also exporting a <CATEGORY>_REGISTRY slug→definition fragment. error-registry.ts is now a barrel that re-exports every definition and assembles ERROR_REGISTRY by spreading the fragments; ErrorSlug, getErrorBySlug, getErrorsByCategory and getAllSlugs are unchanged. Pure reorganization — no behavior change. Verified: the exported const set and the full slug set are byte-identical to before, and the existing error-registry.test.ts passes unchanged. Refs #1989
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits the 842-line
error-registry.ts— a single edit hotspot for all 81 error definitions — into per-category modules. Closes the last#1989audit item (finding #7: monolithic registry → merge contention, hard-to-see category boundaries).How
defineErrorconsts move tosrc/errors/error-registry/<category>.ts(config, build, runtime, route, module, server, boundary, dev, deploy, agent, general). Each file also exports a<CATEGORY>_REGISTRYslug→definition fragment.error-registry.tsbecomes a barrel: itexport *s every category module (so all existing named imports keep working) and assemblesERROR_REGISTRYby spreading the fragments.ErrorSlug,getErrorBySlug,getErrorsByCategory, andgetAllSlugsare unchanged.Safety — pure reorganization, no behavior change
defineErrorconsts (81) and the full slug set (81) are identical tomain(diff empty).error-registry.test.tsalready guards slug uniqueness, registry completeness, and category lookups — all 28 error tests (368 steps) pass against the split.No new test needed — the existing comprehensive registry suite is the regression guard.
Refs #1989