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});
|
callback({success: successfulNumbers, failure: errors});
|
||||||
};
|
};
|
||||||
|
|
||||||
var registerError = function(number, message, error) {
|
var registerError = function(number, reason, error) {
|
||||||
if (!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();
|
numberCompleted();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -137,30 +137,23 @@
|
||||||
this.save({sent: true});
|
this.save({sent: true});
|
||||||
}.bind(this)).catch(function(errors) {
|
}.bind(this)).catch(function(errors) {
|
||||||
this.save({sent: true});
|
this.save({sent: true});
|
||||||
if (errors instanceof Error) {
|
|
||||||
errors = [errors];
|
|
||||||
}
|
|
||||||
var keyErrors = [];
|
|
||||||
_.each(errors, function(e) {
|
|
||||||
console.log(e);
|
|
||||||
console.log(e.stack);
|
|
||||||
if (e.error.name === 'OutgoingIdentityKeyError') {
|
|
||||||
keyErrors.push(e.error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (keyErrors.length) {
|
|
||||||
message.save({ errors : keyErrors });
|
|
||||||
} else {
|
|
||||||
if (!(errors instanceof Array)) {
|
if (!(errors instanceof Array)) {
|
||||||
errors = [errors];
|
errors = [errors];
|
||||||
}
|
}
|
||||||
errors.map(function(e) {
|
errors.forEach(function(e) {
|
||||||
if (e.error && e.error.stack) {
|
console.log(e);
|
||||||
console.error(e.error.stack);
|
console.log(e.reason, e.stack);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
throw errors;
|
message.save({
|
||||||
|
errors : errors.filter(function(e) {
|
||||||
|
switch(e.name) {
|
||||||
|
case 'OutgoingIdentityKeyError':
|
||||||
|
case 'HTTPError':
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
});
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -79,11 +79,13 @@ window.textsecure.messaging = function() {
|
||||||
callback({success: successfulNumbers, failure: errors});
|
callback({success: successfulNumbers, failure: errors});
|
||||||
};
|
};
|
||||||
|
|
||||||
var registerError = function(number, message, error) {
|
var registerError = function(number, reason, error) {
|
||||||
if (!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();
|
numberCompleted();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue