Skip to content

feat: add global error handling middleware#47

Open
morelucks wants to merge 3 commits intoCreditra:mainfrom
morelucks:feature/global-error-handler
Open

feat: add global error handling middleware#47
morelucks wants to merge 3 commits intoCreditra:mainfrom
morelucks:feature/global-error-handler

Conversation

@morelucks
Copy link

feat: add global error handling middleware

Overview

This PR implements a robust, centralized error-handling architecture for the Creditra API. It standardizes error responses, automates HTTP status code mapping, and ensures secure, structured logging across all service routes.

Key Changes

Core Architecture

  • AppError Class: A custom extension of the native Error class designed to carry typed ErrorCodes and optional details for context-rich debugging.
  • Factory Helpers: Implementation of semantic helpers (validationError, notFoundError, authenticationError, etc.) to streamline error creation in route handlers.
  • Unified JSON Envelope: Enforces a consistent response structure across the entire API:
    {
      "error": "Human readable message",
      "code": "ERROR_CATEGORY_CODE",
      "details": { "optional": "metadata" }
    }
    

closes #2

@greatest0fallt1me
Copy link
Contributor

please resolve the conflicts

@morelucks
Copy link
Author

fixed
@greatest0fallt1me

@greatest0fallt1me
Copy link
Contributor

@morelucks Can you resolve the conflicts?

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.

Implement global error handling middleware

2 participants