I'm trying to use request.generateView to generate a custom error page in an 'onRequest' extension function, like so:
server.ext('onRequest', function (request, next) {
if (errorCondition)
next(request.generateView('error', {message: 'Foo'}))
else
next()
})
request.generateView fails in request.js:716 with
Debug: hapi, uncaught, onRequest, error TypeError: Cannot read property 'env' of null
at internals.Request.generateView (.../node_modules/hapi/lib/request.js:716:35)
Changing request.js:716 to
var viewsManager = (this._route && this._route.env.views) || this.server._views;
in order to guard against missing this._route seems to fix it, but I don't know if that's the correct fix. I'm not sure if calling request.generateView at that point is supposed to be supported at all.
I'm trying to use
request.generateViewto generate a custom error page in an'onRequest'extension function, like so:request.generateViewfails in request.js:716 withChanging
request.js:716toin order to guard against missing
this._routeseems to fix it, but I don't know if that's the correct fix. I'm not sure if callingrequest.generateViewat that point is supposed to be supported at all.