Add support for next(err, result) in hooks