Open ggoodman opened 8 years ago
@jhusain currently, when a call
is made to the server for a path that either doesn't exist or has no call
defined, an exception will be thrown by falcor-router
.
That exception is caught by hapi
internals and results in a json
500
response instead of a jsonGraph
response with my own 404
-style error and metadata.
It seems like the structure of this plugin makes it difficult to handle. I suppose a onPostHandler
extension could transform this for the /model.json
path, but this logic would be nicer to have in the plugin itself.
In the spirit of hapi's declarative nature, I think something like this would be nice:
app.route({
method: ['GET', 'POST'],
path: '/model.json',
handler: {
falcor: {
routes: routes, // Your routes
cacheRoutes: true, // Whether to cache your routes, default to true
options: {debug: true}, // Option to give to Falcor router
initialize: function() { // Optional initialize method
this.foo = this.req.payload.meaningoflife || 42;
},
routerClass: MyRouterClass, // Optional routerClass to use
errorSelector: myErrorSelector // NEW: Optional method to handle uncaught exceptions
}
}
});
Would you like to catch them on the client or on the server?