diff --git a/js/background.js b/js/background.js index 74740896180b..8bc517440e66 100644 --- a/js/background.js +++ b/js/background.js @@ -193,16 +193,24 @@ return; } - return ConversationController.findOrCreateById(id, 'private').then(function(conversation) { - return new Promise(function(resolve, reject) { - conversation.save({ - name: details.name, - avatar: details.avatar, - color: details.color, - active_at: conversation.get('active_at') || Date.now(), - }).then(resolve, reject); + return ConversationController.findOrCreateById(id, 'private') + .then(function(conversation) { + return new Promise(function(resolve, reject) { + conversation.save({ + name: details.name, + avatar: details.avatar, + color: details.color, + active_at: conversation.get('active_at') || Date.now(), + }).then(resolve, reject); + }); + }) + .then(ev.confirm) + .catch(function(error) { + console.log( + 'onContactReceived error:', + error && error.stack ? error.stack : error + ); }); - }).then(ev.confirm); } function onGroupReceived(ev) { diff --git a/js/conversation_controller.js b/js/conversation_controller.js index faf11091e580..6972135214d1 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -104,7 +104,14 @@ conversation.fetch().then(function() { resolve(conversation); }, function() { - conversation.save().then(function() { + var deferred = conversation.save(); + + if (!deferred) { + console.log('Conversation save failed! ', id, type); + return reject(new Error('findOrCreateById: Conversation save failed')); + } + + deferred.then(function() { resolve(conversation); }, reject); });