FE-M0-13 · The error-key mapper and enum labels
ID FE-M0-13 · Level L0 · Run order row 28
A refusal from the database shows the text of its error key filled from the JSON detail, else the text of its SQLSTATE class, else error.unknown, reported without the message or details (D10, D29); every key has text, checked by typecheck through the key source OQ24 chose; committed.
Before
Section titled “Before”- FE-M0-12 is Done. You are on the branch web/languages.
- OQ24 is decided in the register, and the backend runbook's Interface answers FE-R7: the enum's name (E1) or how keys are registered in app.error_keys (E2).
1 · Copy the mapper, its tests, the enum labels and the error texts' English
Section titled “1 · Copy the mapper, its tests, the enum labels and the error texts' English”cp -R ~/opleet-v2/packs/fe-pack-d/FE-M0-13/. .2a · If OQ24 chose E1, keys as a Postgres enum: the keys come from the generated types
Section titled “2a · If OQ24 chose E1, keys as a Postgres enum: the keys come from the generated types”cp -R ~/opleet-v2/packs/fe-pack-d/FE-M0-13-E1/. .2b · If OQ24 chose E2, keys kept in apps/web: the list, and typecheck compares it with supabase/migrations
Section titled “2b · If OQ24 chose E2, keys kept in apps/web: the list, and typecheck compares it with supabase/migrations”cp -R ~/opleet-v2/packs/fe-pack-d/FE-M0-13-E2/. .pnpm --dir apps/web pkg set scripts.error-keys="node scripts/error-keys.mjs" scripts.typecheck="node scripts/i18n.mjs --check && node scripts/error-keys.mjs --check && next typegen && tsc --noEmit"3 · Write the catalog again, then test, typecheck and lint
Section titled “3 · Write the catalog again, then test, typecheck and lint”pnpm --filter web i18npnpm --filter web testpnpm --filter web typecheckpnpm lint4 · Commit
Section titled “4 · Commit”git add -A apps/webgit commit -m "feat(web): the error-key mapper and enum labels"Expect
Section titled “Expect”- Block 3: “Keys: 84. With English: 84. Without: 0.”; “ℹ tests 33” and “ℹ pass 33”, with “✔ anything else is error.unknown, reported with its code and never its message or details”; typecheck without errors, and after 2b also “Error keys: 22 in apps/web, 22 registered in supabase/migrations.”; “No fixes applied.”
- Block 4: the commit line with 10 files changed after 2a, or 12 after 2b.
grep -c '^ "error\.' apps/web/i18n/messages.id.tsExpect: 27: the 22 keys, the 4 SQLSTATE classes and error.unknown.
If it fails
Section titled “If it fails”- After 2a, typecheck says lib/errors/texts.ts lacks a key or has one the enum doesn't: paste the error; FE adds or removes that text.
- After 2a, “Property 'error_key' does not exist”: the enum has another name. Paste the name from the backend runbook's Interface.
- After 2b, “Found no keys registered in app.error_keys”: the migrations register keys another way. Paste one registration line from supabase/migrations and stop.
- After 2b, a key registered in supabase/migrations but not in lib/errors/keys.ts, or the reverse: paste the lines.
git reset --hardgit clean -fd apps/webBefore the commit. After it: git reset --hard HEAD~1.
Not run yet.