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 of the database's enum has text, checked by typecheck (D30); committed.
Before
Section titled “Before”- FE-M0-12 is Done. You are on the branch web/languages.
- The generated types in packages/db-types hold the enum
error_key(D30: the keys are a Postgres enum, so OQ24 is closed with E1). The pack reads it asDatabase["public"]["Enums"]["error_key"].
1 · Check the two catalog files this step replaces, then copy the mapper, its tests, the key list, the enum labels and the error texts' English
Section titled “1 · Check the two catalog files this step replaces, then copy the mapper, its tests, the key list, the enum labels and the error texts' English”shasum -a 256 -c ~/opleet-v2/packs/fe-pack-d/FE-M0-13/BASE.sha256 && cp -R ~/opleet-v2/packs/fe-pack-d/FE-M0-13/apps .2 · Show the keys the enum holds, so the texts can be checked against them
Section titled “2 · Show the keys the enum holds, so the texts can be checked against them”grep -o '"error_key": \[[^]]*\]' packages/db-types/src/*.ts | tr ',' '\n' | wc -l3 · 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 1: two lines ending in “: OK”, for i18n/messages.en.ts and i18n/strict.json.
- Block 2: 23, the number of keys in the enum.
- Block 3: “Keys: 86. With English: 86. 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; “No fixes applied.”
- Block 4: the commit line with 10 files changed.
grep -c '^ "error\.' apps/web/i18n/messages.id.tsExpect: 29: the 23 keys, error.internal.unknown_error_key (the key the database raises when a function names a key the enum lacks, R-CONV; the mapper shows a general text and reports it), the 4 SQLSTATE classes and error.unknown.
If it fails
Section titled “If it fails”- Block 1 prints “FAILED” for a file and stops: your copy of that file is not the one this step was written for (main has changed it, or it was edited by hand). Nothing was copied. Paste the FAILED lines and stop; FE rebuilds the step. If you fixed files by hand on an earlier try, start again from main: run FE-M0-12's Undo, then FE-M0-12 from block 2.
- Typecheck says lib/errors/texts.ts lacks a key or has one the enum doesn't: a migration has added or dropped a key since this pack was written. Paste the error; FE adds or removes that text.
- “Property 'error_key' does not exist”: packages/db-types was not regenerated after BE pack B. Paste
grep -c error_key packages/db-types/src/*.ts.
git reset --hardgit clean -fd apps/webBefore the commit. After it: git reset --hard HEAD~1.
Not run yet.