basic erro r handling for 404 sites

This commit is contained in:
2020-01-05 00:12:11 -05:00
parent effc4db088
commit 7d09bfafb3
2 changed files with 12 additions and 5 deletions

View File

@ -4,9 +4,12 @@ module.exports = {
// Find site by ID export
findById: function(req, res){
Site.findById(req.params.id, function(err, site){
if(err) throw err;
console.log("Site->Controller: findById queried: " + site.site);
res.render('site', { title: site.site, site: site });
// if(err) throw err;
if(err) res.render('index', { title: 'Site is not found!'});
else {
console.log("Site->Controller: findById queried: " + site.site);
res.render('site', { title: site.site, site: site });
}
});
}
}