Skip to content

[WIP] Implement Global Error Handling Middleware for Hero API - #24

Draft
mrkuon12354 wants to merge 2 commits into
HermanL0201:e76a0895-0a2b-426e-b43b-059fa02aee8ffrom
mrkuon12354:feat-global-error-middleware-1749259410
Draft

[WIP] Implement Global Error Handling Middleware for Hero API#24
mrkuon12354 wants to merge 2 commits into
HermanL0201:e76a0895-0a2b-426e-b43b-059fa02aee8ffrom
mrkuon12354:feat-global-error-middleware-1749259410

Conversation

@mrkuon12354

Copy link
Copy Markdown

Implement Global Error Handling Middleware for Hero API

Description

Task

Add basic error handling middleware

Acceptance Criteria

  • Middleware handles both synchronous and asynchronous errors
  • Error responses have a standardized JSON structure
  • Appropriate HTTP status codes are returned based on error type
  • Errors are logged for debugging purposes
  • No sensitive information is leaked in error responses

Summary of Work

This pull request adds a centralized error handling middleware to the Hero API to ensure consistent error responses and improve error tracking and debugging capabilities.

Changes Made

  • Create a new middleware file: src/middleware/errorHandler.ts
  • Implement global error handling logic to catch and process unhandled errors
  • Define a consistent error response format
  • Add error type classification and appropriate HTTP status codes
  • Integrate error handling middleware into the main Express application

Tests

  • Verify middleware catches unhandled errors
  • Confirm consistent error response structure
  • Test different error scenarios (404, 500, validation errors)
  • Ensure sensitive error details are not exposed in production
  • Validate logging of error events

Signatures

Staking Key

BXzBH5MrNbifDx8ELB6LfjkZpvWfEUjajF6aBKvvxQAh: 8LALAWu5RePnmzqErr3smNJ8SfdMqmiPaTMjgWot3zS3Ei7rhSsPy2iz3Hb5gzNpWBWbfJ7ZgnoujezoSK1KjmrSHSmMKTngkVAZbm5sNeaT7MRbvqGMAtS1wfj6x13GXGnNPwcZEhxLdPqc2bPqRN4Uc8UgF4othBT9pS1rmMz5V2mD7VUHAd8QWjPrDd1JVGsZPdmMugUvpcdrw5zRrN32SKnK1Ay2drjYTAeryoognKB5bUx3g7vPF3cSfPjCnRugVx5tWQHHckFamopw8dv136FGSMzvtpE3V98BUst53GQfpygSuA5pz7L7NzzmWCubcBKTV7k1A529X1Fx6bEmLhHTB28jgenkDV8C65xy7gB3N4i3S7knaEGs662wNbfyZzf9gxhVqoRN7ohaygTxAwFYYbEf95v

Public Key

25aNKzScY6d45qv1iCuzwh3SjHAQudP3cphJoRMqJyY5: 2pN6qcPAMSNjB8mPKAy65HAwvVBaA8Dv21uF5wYDhqCJvQBNTUows87VpGDza4QJaAXc3jney9k4CQfvcmzRTHdz4jHVw8HnQjtLZM52Z1uec2sv8GComLQLiGe3FG9LwTYGofcnMxte7ifftkm9uUA4HyTKov22QeVBKdv97Yz4o4A9BHHQunZ9mr9h5KYiNsVMGpttmNchB5THdkAGy3bXuuYuygDpTHYnhTPGV6G47Js4Sp8Jd8MgNBnfGQuPHcp7PW84hhZFPWK6kvJWv9toh7j7qoXayXfQJB3WJY3B7sYY82Cozdq7piiycBeFFSJsYR9x8Xp1HGJNK8s6qchw2hHYVjwX3heqJBqnghtEjk8QhmMx7iL1rEatPUqM8AwkY3aNVMp7UwNnSBJWa4a2yPnS2AdQm2kC

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.

1 participant