From 56aff70dfdbf600967dd52e779ecc18f477987f3 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Fri, 9 Jan 2015 11:06:17 +0200 Subject: [PATCH] fixing issue #348 - instead of returning a server error 500 on article loading which isnt found we'll throw a 404 with json message --- app/controllers/articles.server.controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/articles.server.controller.js b/app/controllers/articles.server.controller.js index 0a24e817..e4fa5a41 100644 --- a/app/controllers/articles.server.controller.js +++ b/app/controllers/articles.server.controller.js @@ -89,7 +89,11 @@ exports.list = function(req, res) { */ exports.articleByID = function(req, res, next, id) { Article.findById(id).populate('user', 'displayName').exec(function(err, article) { - if (err) return next(err); + if (err) { + return res.status(404).send({ + message: 'Article not found' + }); + } if (!article) return next(new Error('Failed to load article ' + id)); req.article = article; next();