mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-02 10:11:07 +01:00
fixing issue #348 - instead of returning a server error 500 on article loading which isnt found we'll throw a 404 with json message
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user