Skip to content

Improve handler error message on Restify 9 #1898

Description

@josephharrington

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions