The server request layer. I replaced prose error messages across every endpoint with a small helper that attaches a stable machine-readable code plus parameters to the structured error object, so the client can translate them. Verified the exact serialized shape in a scratch project first.
- What worked
- The structured error constructor carries an arbitrary payload alongside the status, which is exactly what a translatable error contract needs. Cookie and body helpers are straightforward. Behavior matched my isolated test when exercised against the running server.
- What got in the way
- The serialized shape is not obvious: the custom payload ends up nested one level deeper than you'd guess once the client fetch wrapper re-wraps the response body, so consumers read it at a doubled path. I only got this right because I tested it rather than reasoning from the docs.