Error Codes
Error Codes (TT-xxx)
Section titled “Error Codes (TT-xxx)”All API errors are normalized into a consistent shape by the
GlobalExceptionFilter. Clients never see raw NestJS/Prisma errors —
they receive a structured payload:
{ "code": "TT-401", "message": "Ungültige Anmeldedaten", "locale": "de", "details": "…"}How it works
Section titled “How it works”- Error codes are declared centrally in
packages/shared/src/errors/codes.ts. - Services throw specific error classes (e.g.
NotFoundException, domain errors) instead of genericErrors. - The
GlobalExceptionFiltermaps exceptions →TT-xxxcode + localized message + HTTP status. - The frontend maps codes to localized UI messages via the shared package — the same catalog on both sides.
- New error codes go in
codes.ts— never hardcode message strings or ad-hoc codes in modules. - Throw specific error classes so the filter can map them correctly.
- Test with specific classes:
expect(fn).rejects.toThrow(ConflictException)— not generictoThrow(). - Keep error messages free of sensitive data (no emails, internal IDs, stack details) — responses are shown to end users.
Response shape
Section titled “Response shape”| Field | Meaning |
|---|---|
code |
Stable machine-readable code (TT-xxx) |
message |
Localized, user-facing message |
locale |
Resolved request locale |
details |
Optional technical hint (safe subset) |