Skip to content

Instantly share code, notes, and snippets.

@savelee
Created August 16, 2016 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save savelee/5725786617a7348cf0505255c95a9f7a to your computer and use it in GitHub Desktop.
Save savelee/5725786617a7348cf0505255c95a9f7a to your computer and use it in GitHub Desktop.
server/components/errors/index.js
'use strict';
var path = require('path');
var config = require('../../config');
module.exports[404] = function pageNotFound(req, res) {
var viewFilePath = path.join(config.root, 'server/views/404.html');
var statusCode = 404;
var result = {
status: statusCode
};
res.status(result.status);
res.sendFile(viewFilePath, function (err) {
// if the file doesn't exist of there is an error reading it just return a json with the error
if (err) {
return res.json(result, result.status);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment