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

Improve handler error message on Restify 9 #1898

Closed
josephharrington opened this issue Mar 30, 2022 · 0 comments · Fixed by #1901
Closed

Improve handler error message on Restify 9 #1898

josephharrington opened this issue Mar 30, 2022 · 0 comments · Fixed by #1901
Labels

Comments

@josephharrington
Copy link
Contributor

Feature Request

Use Case

If you define a handler and leave off the third param next, then restify 9 gives the error message:

AssertionError [ERR_ASSERTION]: 'Function' == 'AsyncFunction'
    at Chain.add (.../node_modules/restify/lib/chain.js:78:16)

The assertion is meant to distinguish between async and callback handlers, but is misleading in the case of a misdefined callback handler. Also, there's no info in the error about which handler caused the error. The error should say something like:

Handler "getCandy" was expected to either be an async function with two parameters or a callback handler with three parameters (req, res, next).
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 a pull request may close this issue.

1 participant