Remove sending 500 response to user manually and rely on middleware instead
This commit is contained in:
@ -49,7 +49,6 @@ exports.recentJSON = function(req, res, next) {
|
|||||||
var story = Story.find({}).sort({'timePosted': -1}).limit(100);
|
var story = Story.find({}).sort({'timePosted': -1}).limit(100);
|
||||||
story.exec(function(err, stories) {
|
story.exec(function(err, stories) {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.sendStatus(500);
|
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
return res.json(stories);
|
return res.json(stories);
|
||||||
@ -215,7 +214,6 @@ exports.upvote = function(req, res, next) {
|
|||||||
var data = req.body.data;
|
var data = req.body.data;
|
||||||
Story.find({'_id': data.id}, function(err, story) {
|
Story.find({'_id': data.id}, function(err, story) {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.sendStatus(500);
|
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
story = story.pop();
|
story = story.pop();
|
||||||
@ -245,7 +243,6 @@ exports.comments = function(req, res, next) {
|
|||||||
var data = req.params.id;
|
var data = req.params.id;
|
||||||
Comment.find({'_id': data}, function(err, comment) {
|
Comment.find({'_id': data}, function(err, comment) {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.sendStatus(500);
|
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
comment = comment.pop();
|
comment = comment.pop();
|
||||||
|
Reference in New Issue
Block a user