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

@ -19,8 +19,12 @@ Site.findById = function(id, callback){
con.query(sql, id, function(err, result){
if (err) return callback(err);
console.log("Site.findById: " + result[0].site + " retrieved!");
callback(err, new Site(result[0]));
// if not site is found.
if (result[0] == undefined) callback(404);
else {
console.log("Site.findById: " + result[0].site + " retrieved!");
callback(err, new Site(result[0]));
}
});
};