Skip to content

Add standard error response formatting helper for Fastify exception handling #452

Description

@Cjay-Cyber-2

Description

Create a standardized error response formatter utility to ensure all Fastify error replies return a consistent JSON structure containing timestamp, error code, message, and request ID.

Context & Requirements

Consistent error structures improve developer experience for frontend integration (mergepay-web). Fastify's setErrorHandler can be leveraged to format unhandled exceptions and validation errors uniformly.

Acceptance Criteria

  • Implement or refine setErrorHandler in the Fastify server configuration.
  • Ensure Zod validation errors return formatted 400 responses with detailed issue lists.
  • Ensure internal server errors return structured 500 responses without leaking stack traces in production.

Implementation Guidance

  • Likely files to touch: src/index.ts or error handling middleware modules.
  • Integrate with the request ID propagation feature already established in the codebase.

Testing & Validation

  • Add unit or integration tests verifying error response payloads for invalid requests.
  • Run npm test.

Submission Guidelines

  • Open a Pull Request referencing Closes #<issue-number>.
  • Adhere to TypeScript strict rules and existing codebase formatting standards.

Wave complexity: Trivial

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programbackendcomplexity: trivialDrips Wave — small, well-bounded taskdrips-waveTracked in a Drips Wave programenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions