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

ch-Add a global error handler middleware #26

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Conversation

Calebgisa72
Copy link
Contributor

What does this PR do?
This pull request implements a global error handling middleware in the knights-ecomm-be project to enhance error management and user experience.

Description of Task Completed:
The task accomplished in this pull request involves:

  • Implementing a middleware function to catch unhandled errors globally.
  • Defining a custom error class (CustomError) to encapsulate error details including status code and status.
  • Developing an error handling middleware (errorHandler) to provide informative error responses.
  • Integrating the error handling middleware into the Express application to handle errors across all routes.

How should this be manually tested?
To manually test all the changes made in this pull request, follow these steps:
git clone -b branch-name https://github.com/your-username/knights-ecomm-be.git

cd knights-ecomm-be
npm i
npm run dev
Make a request using postman.

Copy link
Contributor

@elijahladdie elijahladdie left a comment

Choose a reason for hiding this comment

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

@Calebgisa72 Looks Good🎉!

Copy link
Collaborator

@faid-terence faid-terence left a comment

Choose a reason for hiding this comment

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

You should have updated version of develop @Calebgisa72 !

@elijahladdie elijahladdie self-requested a review April 25, 2024 22:39
Copy link
Contributor

@elijahladdie elijahladdie left a comment

Choose a reason for hiding this comment

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

@Calebgisa72, You are not using errorHandler in the project root which is resulting error can you please include it in src/index.ts
it should be something like this app.use(errorHandler);

@Calebgisa72 Calebgisa72 force-pushed the ch-error-handling branch 2 times, most recently from 3b47555 to 9ae63a7 Compare April 26, 2024 08:08
Copy link
Collaborator

@faid-terence faid-terence left a comment

Choose a reason for hiding this comment

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

Nice Work @Calebgisa72 !

@faid-terence faid-terence merged commit 41f0fe0 into develop Apr 26, 2024
1 check passed
@Calebgisa72 Calebgisa72 changed the title Added a global error handler middleware ch-Add a global error handler middleware Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready for reviews Pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants