Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to send different error response from error handler middleware #2372

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

pankajjs
Copy link
Member

@pankajjs pankajjs commented Jan 26, 2025

Date: 26 Jan, 2025

Developer Name: @pankajjs


Issue Ticket Number

Description

This PR fixes the error handler middleware by adding support to send different error responses based on error types.

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1

Test Coverage

Screenshot 1

Additional Notes

@pankajjs pankajjs self-assigned this Jan 26, 2025
@@ -23,12 +23,13 @@ app.use(function (req, res, next) {
});

// error handler
app.use(function (err, req, res, next) {
app.use(function (err, req, res, _next) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_next why this change ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good practise to prefix the variable with underscore when it is unused in the function but required in function parameter. It also prevents warning.
Considering it, I have added _ before next middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix error handler middleware to serve different error response
2 participants