{"action":"closed","issue":{"url":"https://api.github.com/repos/expressjs/vhost/issues/14","labels_url":"https://api.github.com/repos/expressjs/vhost/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/vhost/issues/14/comments","events_url":"https://api.github.com/repos/expressjs/vhost/issues/14/events","html_url":"https://github.com/expressjs/vhost/issues/14","id":100297724,"number":14,"title":"Can't catch 404/500 errors","user":{"login":"greggilbert","id":169482,"avatar_url":"https://avatars.githubusercontent.com/u/169482?v=3","gravatar_id":"","url":"https://api.github.com/users/greggilbert","html_url":"https://github.com/greggilbert","followers_url":"https://api.github.com/users/greggilbert/followers","following_url":"https://api.github.com/users/greggilbert/following{/other_user}","gists_url":"https://api.github.com/users/greggilbert/gists{/gist_id}","starred_url":"https://api.github.com/users/greggilbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/greggilbert/subscriptions","organizations_url":"https://api.github.com/users/greggilbert/orgs","repos_url":"https://api.github.com/users/greggilbert/repos","events_url":"https://api.github.com/users/greggilbert/events{/privacy}","received_events_url":"https://api.github.com/users/greggilbert/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/expressjs/vhost/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"dougwilson","id":67512,"avatar_url":"https://avatars.githubusercontent.com/u/67512?v=3","gravatar_id":"","url":"https://api.github.com/users/dougwilson","html_url":"https://github.com/dougwilson","followers_url":"https://api.github.com/users/dougwilson/followers","following_url":"https://api.github.com/users/dougwilson/following{/other_user}","gists_url":"https://api.github.com/users/dougwilson/gists{/gist_id}","starred_url":"https://api.github.com/users/dougwilson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougwilson/subscriptions","organizations_url":"https://api.github.com/users/dougwilson/orgs","repos_url":"https://api.github.com/users/dougwilson/repos","events_url":"https://api.github.com/users/dougwilson/events{/privacy}","received_events_url":"https://api.github.com/users/dougwilson/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2015-08-11T12:07:22Z","updated_at":"2015-08-12T04:10:01Z","closed_at":"2015-08-12T04:10:01Z","body":"Hey. Quick question: where do you recommend putting the functions to do error handling? Express 4 documentation says to use `app.use(function(err, req, res, next)` after all the regular routing goes in. I had it in my vhost-specific files, but it's not properly catching 404s. I moved it up to the to `app.js` as below, but it still doesn't work for some reason. Sample:\r\n\r\n```\r\nvar firstApp = require('./first/app');\r\nvar secondApp = require('./second/app');\r\n// ...\r\napp.use(vhost('app.test', secondApp))\r\n    .use(vhost(/.*/, firstApp));\r\n// ...\r\napp.use(function(err, req, res, next) {\r\n  res.status(err.status || 500);\r\n  res.render('error', {\r\n    message: err.message,\r\n    error: {}\r\n  });\r\n});\r\n```\r\n\r\nAnd then `first/app.js` and `second/app.js` are just creating `express()` apps and then exporting them. Any idea on how to properly do error catching?"}}