From ed8e76ebced46d06b1691ec955ac0d90b2be914b Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 24 Feb 2014 16:01:01 -0500 Subject: [PATCH] added error check to getTopicDataWithUser --- src/topics.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/topics.js b/src/topics.js index 51a7008ef9..ca7c134831 100644 --- a/src/topics.js +++ b/src/topics.js @@ -325,13 +325,13 @@ var async = require('async'), Topics.getTopicDataWithUser = function(tid, callback) { Topics.getTopicData(tid, function(err, topic) { - if(err) { - return callback(err, null); + if(err || !topic) { + return callback(err || new Error('topic doesn\'t exist')); } user.getUserFields(topic.uid, ['username', 'userslug', 'picture'] , function(err, userData) { if(err) { - return callback(err, null); + return callback(err); } topic.username = userData.username; @@ -859,11 +859,7 @@ var async = require('async'), } function getReadStatus(next) { - if (uid && parseInt(uid, 10) > 0) { - Topics.hasReadTopic(tid, uid, next); - } else { - next(null, null); - } + Topics.hasReadTopic(tid, uid, next); } function getTeaser(next) {