Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
fixing issue #348 - instead of returning a server error 500 on articl…
Browse files Browse the repository at this point in the history
…e loading which isnt found we'll throw a 404 with json message
  • Loading branch information
lirantal committed Jan 9, 2015
1 parent bde2412 commit 56aff70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/controllers/articles.server.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 56aff70

Please sign in to comment.