lukeed/polka

custom error handler cannot call next()

eco747 opened this issue · 0 comments

as stated in the onError documentation:

Caution: Use next() to bypass certain errors at your own risk!
You must be certain that the exception will be handled elsewhere or can be safely ignored.
Otherwise your response will never terminate!

It should be cool to set 'next' to the default onError in the call of the custom procedure.

ie instead of (in the polka ctor):

this.onError = opts.onError || onError; // catch-all handler

somethink like:

this.onError = onError;
if( opts.onError ) {
    this.onError = function( err, req, res, next ) {
         opts.onError( err, req, res, onError );
    }
}