Skip to content

fix(backend): align domain error response envelope with Nest default …#3

Merged
maaref-insat merged 2 commits into
mainfrom
bug/fix_code_error_messages
Jul 17, 2026
Merged

fix(backend): align domain error response envelope with Nest default …#3
maaref-insat merged 2 commits into
mainfrom
bug/fix_code_error_messages

Conversation

@omarmaaref

Copy link
Copy Markdown
Owner

…shape

DomainExceptionFilter previously emitted { statusCode, code, message } while Nest's built-in HttpException emits { statusCode, message, error }. The two shapes coexisting across the same API surface meant clients had to branch on which endpoint they hit to know which field to read.

Rename the filter's output field from 'code' to 'error' so every JSON error body has the same key layout regardless of whether it originated in the domain filter (fleet-management rule violations) or in a Nest exception (vehicle CRUD 404s, ValidationPipe failures, ...). The stored value is unchanged — it still carries the machine-readable domain code like VEHICLE_ALREADY_ASSIGNED.

Swagger examples in vehicles / operators / fleet-management openapi.ts updated to reflect the new key.

Operator dashboard is updated in the same commit — its api.ts parses body.error into ApiError.code, and the ApiErrorBody type renames the wire field. Internal ApiError.code stays as-is to avoid touching every call site.

Summary

Changes

  • Backend:
  • Frontend:
  • Infra / CI:
  • Docs:

Testing

  • npm test in apps/backend passes
  • npx tsc --noEmit passes in both apps
  • Manually verified via the operator dashboard
  • Manually verified via the Swagger UI at /docs

Notes for reviewers

…shape

DomainExceptionFilter previously emitted { statusCode, code, message }
while Nest's built-in HttpException emits { statusCode, message, error }.
The two shapes coexisting across the same API surface meant clients had
to branch on which endpoint they hit to know which field to read.

Rename the filter's output field from 'code' to 'error' so every JSON
error body has the same key layout regardless of whether it originated
in the domain filter (fleet-management rule violations) or in a Nest
exception (vehicle CRUD 404s, ValidationPipe failures, ...). The stored
value is unchanged — it still carries the machine-readable domain code
like VEHICLE_ALREADY_ASSIGNED.

Swagger examples in vehicles / operators / fleet-management openapi.ts
updated to reflect the new key.

Operator dashboard is updated in the same commit — its api.ts parses
body.error into ApiError.code, and the ApiErrorBody type renames the
wire field. Internal ApiError.code stays as-is to avoid touching every
call site.
@maaref-insat
maaref-insat merged commit b1cee8b into main Jul 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants