Handle attachment upload errors

Adds a new kind of replayable error that handles retry of pre-encryption
failures, e.g., attachment upload.

Fixes #485

// FREEBIE
This commit is contained in:
lilia 2016-02-05 16:42:53 -08:00
parent 910e37649a
commit 7e82d1295c
5 changed files with 64 additions and 17 deletions

View file

@ -9,6 +9,7 @@
ENCRYPT_MESSAGE: 1,
INIT_SESSION: 2,
TRANSMIT_MESSAGE: 3,
REBUILD_MESSAGE: 4,
};
window.textsecure = window.textsecure || {};
window.textsecure.replay = {
@ -87,10 +88,25 @@
SendMessageNetworkError.prototype = new ReplayableError();
SendMessageNetworkError.prototype.constructor = SendMessageNetworkError;
function MessageError(message, httpError) {
ReplayableError.call(this, {
functionCode : Type.REBUILD_MESSAGE,
args : [message]
});
this.name = 'MessageError';
this.code = httpError.code;
this.message = httpError.message;
this.stack = httpError.stack;
}
MessageError.prototype = new ReplayableError();
MessageError.prototype.constructor = MessageError;
window.textsecure.SendMessageNetworkError = SendMessageNetworkError;
window.textsecure.IncomingIdentityKeyError = IncomingIdentityKeyError;
window.textsecure.OutgoingIdentityKeyError = OutgoingIdentityKeyError;
window.textsecure.ReplayableError = ReplayableError;
window.textsecure.OutgoingMessageError = OutgoingMessageError;
window.textsecure.MessageError = MessageError;
})();