Skip to content

Add a Global HTTP Exception Filter That Returns a Consistent JSON Error Shape Across All Endpoints #226

@mftee

Description

@mftee

Description:
Add a standalone global HTTP exception filter that returns consistent, structured error responses across the entire API.

Tasks:

  • Create src/common/filters/http-exception.filter.ts implementing ExceptionFilter
  • Catch all HttpException and generic Error instances
  • Return a uniform JSON shape: { statusCode, message, error, timestamp, path }
  • Register the filter globally in main.ts
  • Map unhandled Error instances to 500 Internal Server Error without leaking stack traces in production (NODE_ENV=production)

Acceptance Criteria:

  • All API error responses follow the defined JSON shape
  • Stack traces are hidden in production but logged server-side
  • Validation errors from the global ValidationPipe are also formatted by this filter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions