Created
August 16, 2016 13:33
-
-
Save savelee/5725786617a7348cf0505255c95a9f7a to your computer and use it in GitHub Desktop.
server/components/errors/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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