Skip to main content

Error Handling

Last reviewed: 2026-05-13
Maintained by: Engineering

The API uses a structured error envelope with consistent request correlation.

Current behavior

  • request validation failures return a sanitized validation response
  • domain and business-rule failures use AppError
  • unexpected failures return a generic 500 envelope in production
  • server-side logs and optional Sentry capture record the failure with request context

Key implementation areas

  • error middleware: apps/api/src/middlewares/error-handler.ts
  • domain error classes: apps/api/src/lib/errors.ts
  • response envelope helpers: apps/api/src/lib/response-envelope.ts