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

Added support for router specific error handler #328

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

zeta-squared
Copy link

@zeta-squared zeta-squared commented Dec 9, 2024

Related open issues: #308

I have added support for router-specific error handlers, with a view to support router-specific not found handlers if this PR is successful. Slight changes have also been made to the docs to reflect the new feature. All current branch tests pass so I don't believe there are any breaking changes in this request.

I do note though that in the throw method on Response because the error handlers were not originally called in a return statement the control is still passed to middleware and in some instances breaks the expected behaviour of the error handler itself. For this reason I have also made a change to this method to preserve the expected behaviour of the error handler.

If this is a PR that will be accepted I do plan to add tests using supertest and jest (purely to simplify the testing for myself) to ensure the error handlers behave as expected. As mentioned above, I believe there is a natural progression here to add support for router-specific not found handlers and again if this PR is accepted I will look to continue in this direction. A small demo can be found here

EDIT: The earlier encountered problem with the Response.throw method was an artifact of my tsconfig in the demo. I have reverted this change and updated the demo repo.

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