Skip to content

Error Codes

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": ""
}
  1. Error codes are declared centrally in packages/shared/src/errors/codes.ts.
  2. Services throw specific error classes (e.g. NotFoundException, domain errors) instead of generic Errors.
  3. The GlobalExceptionFilter maps exceptions → TT-xxx code + localized message + HTTP status.
  4. 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 generic toThrow().
  • Keep error messages free of sensitive data (no emails, internal IDs, stack details) — responses are shown to end users.
Field Meaning
code Stable machine-readable code (TT-xxx)
message Localized, user-facing message
locale Resolved request locale
details Optional technical hint (safe subset)