improvement: some files replaced, lots of them i shall say. AGENT.MD file created. some rules and skills added for cursor agent.
This commit is contained in:
28
.cursor/rules/api-errors-i18n.mdc
Normal file
28
.cursor/rules/api-errors-i18n.mdc
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
description: Error codes backend ↔ frontend and i18n message keys
|
||||
globs: backend/src/common/errors/**,frontend/src/components/shared/formatApiError.ts,frontend/messages/**
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# API errors & translations
|
||||
|
||||
## Adding a new error
|
||||
|
||||
1. Add code to `backend/src/common/errors/error-codes.ts`
|
||||
2. Throw via `AppException` (or validation DTO with that code)
|
||||
3. Add matching key under `errors` in **all three** message files:
|
||||
- `frontend/messages/en.json`
|
||||
- `frontend/messages/fa.json`
|
||||
- `frontend/messages/nl.json`
|
||||
4. Frontend catch: `getUserFacingError(err, tErrors, t('fallbackKey'))`
|
||||
|
||||
## Validation field errors
|
||||
|
||||
Backend returns `{ success: false, error: { code, details: [{ field, code }] } }`.
|
||||
|
||||
Frontend maps `details[].code` through the `errors` namespace.
|
||||
|
||||
## Do not
|
||||
|
||||
- Show raw `error.message` or stack traces to users.
|
||||
- Add English-only strings inline in components.
|
||||
Reference in New Issue
Block a user