Skip to content

refactor(errors): split error-registry into per-category modules (#1989) - #2051

Merged
ariskemper merged 1 commit into
mainfrom
refactor/1989-error-registry-split
Jun 2, 2026
Merged

refactor(errors): split error-registry into per-category modules (#1989)#2051
ariskemper merged 1 commit into
mainfrom
refactor/1989-error-registry-split

Conversation

@ariskemper

Copy link
Copy Markdown
Contributor

What

Splits the 842-line error-registry.ts — a single edit hotspot for all 81 error definitions — into per-category modules. Closes the last #1989 audit item (finding #7: monolithic registry → merge contention, hard-to-see category boundaries).

How

  • Each category's defineError consts move to src/errors/error-registry/<category>.ts (config, build, runtime, route, module, server, boundary, dev, deploy, agent, general). Each file also exports a <CATEGORY>_REGISTRY slug→definition fragment.
  • error-registry.ts becomes a barrel: it export *s every category module (so all existing named imports keep working) and assembles ERROR_REGISTRY by spreading the fragments. ErrorSlug, getErrorBySlug, getErrorsByCategory, and getAllSlugs are unchanged.

Safety — pure reorganization, no behavior change

  • Byte-identical exports: verified the set of exported defineError consts (81) and the full slug set (81) are identical to main (diff empty).
  • Existing suite passes unchanged: error-registry.test.ts already guards slug uniqueness, registry completeness, and category lookups — all 28 error tests (368 steps) pass against the split.
  • Typecheck + lint clean; doc-comments on individual definitions preserved.

No new test needed — the existing comprehensive registry suite is the regression guard.

Refs #1989

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
@ariskemper
ariskemper marked this pull request as ready for review June 2, 2026 12:07
@ariskemper
ariskemper merged commit 97184c3 into main Jun 2, 2026
19 checks passed
@ariskemper
ariskemper deleted the refactor/1989-error-registry-split branch June 2, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant