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

Could a router have a specific error handler ? #308

Open
kapouer opened this issue Oct 10, 2024 · 2 comments
Open

Could a router have a specific error handler ? #308

kapouer opened this issue Oct 10, 2024 · 2 comments

Comments

@kapouer
Copy link

kapouer commented Oct 10, 2024

I understand that the (err, req, res, next) signature is not supported, however,
that feature is really missing.
For example, my app have three separate routers with totally different behaviors:

  • generates html pages
  • the api
  • static files

and each router needs to deal with errors very differently.

@kartikk221
Copy link
Owner

kartikk221 commented Oct 11, 2024

Hello, as you may have read from previous issues and documentation, the hyper-express middleware system at the moment is very different from Express.js in both its operation and internal logic.

  • Middlewares and Routes are different without sharing the same signature.
  • Middlewares execute in a hierarchical manner where order is GLOBAL -> LOCAL -> ROUTE_SPECIFIC

Unfortunately, we only support a global error handler at the moment. I do think that a router specific error handler should be possible in theory since it would be an additive change rather than a breaking one.

Do you have reference on the signature, behavior and expectation of this feature?

@kapouer
Copy link
Author

kapouer commented Oct 11, 2024

A router-specific error handler would just have to get the error and be able to res.send() something.

Also while you are considering this, I think currently hyper-express doesn't catch errors when calling a middleware with (req, res, next) signature ?

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

No branches or pull requests

2 participants