basic erro r handling for 404 sites
This commit is contained in:
@ -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]));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user