Un-nest libtextsecure errors
Fix inconsistency in error format, where we sometimes get an unexpected Error object and sometimes get a wrapper object containing an Error. Also start saving network errors. // FREEBIE
This commit is contained in:
parent
1879e73c76
commit
04c5f83485
3 changed files with 22 additions and 25 deletions
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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));
|
||||
},
|
||||
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue