diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 10561bb9dbc8..20355de94805 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39758,11 +39758,13 @@ window.textsecure.messaging = function() { callback({success: successfulNumbers, failure: errors}); }; - var registerError = function(number, message, error) { + var registerError = function(number, reason, error) { if (!error) { - error = new Error(message); + error = new Error(reason); } - errors[errors.length] = { number: number, reason: message, error: error }; + error.number = number; + error.reason = reason; + errors[errors.length] = error; numberCompleted(); }; diff --git a/js/models/messages.js b/js/models/messages.js index da99fc390674..bbdd3ae72650 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -137,30 +137,23 @@ this.save({sent: true}); }.bind(this)).catch(function(errors) { this.save({sent: true}); - if (errors instanceof Error) { + if (!(errors instanceof Array)) { errors = [errors]; } - var keyErrors = []; - _.each(errors, function(e) { + errors.forEach(function(e) { console.log(e); - console.log(e.stack); - if (e.error.name === 'OutgoingIdentityKeyError') { - keyErrors.push(e.error); - } + console.log(e.reason, e.stack); }); - if (keyErrors.length) { - message.save({ errors : keyErrors }); - } else { - if (!(errors instanceof Array)) { - errors = [errors]; - } - errors.map(function(e) { - if (e.error && e.error.stack) { - console.error(e.error.stack); + message.save({ + errors : errors.filter(function(e) { + switch(e.name) { + case 'OutgoingIdentityKeyError': + case 'HTTPError': + return true; } - }); - throw errors; - } + return false; + }) + }); }.bind(this)); }, diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 6c643b082086..1befaba2cc88 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -79,11 +79,13 @@ window.textsecure.messaging = function() { callback({success: successfulNumbers, failure: errors}); }; - var registerError = function(number, message, error) { + var registerError = function(number, reason, error) { if (!error) { - error = new Error(message); + error = new Error(reason); } - errors[errors.length] = { number: number, reason: message, error: error }; + error.number = number; + error.reason = reason; + errors[errors.length] = error; numberCompleted(); };