From f5852bb357a982b5fc2d76bdc31c27dc7930ac48 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 13 Jul 2018 08:59:18 -0700 Subject: [PATCH] Be resilient to null thrown errors so we can surface to user --- js/background.js | 7 ++++--- libtextsecure/message_receiver.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/background.js b/js/background.js index 9fc52fb57b42..0627797dc461 100644 --- a/js/background.js +++ b/js/background.js @@ -819,6 +819,7 @@ console.log('background onError:', Errors.toLogFormat(error)); if ( + error && error.name === 'HTTPError' && (error.code === 401 || error.code === 403) ) { @@ -847,7 +848,7 @@ return; } - if (error.name === 'HTTPError' && error.code === -1) { + if (error && error.name === 'HTTPError' && error.code === -1) { // Failed to connect to server if (navigator.onLine) { console.log('retrying in 1 minute'); @@ -859,7 +860,7 @@ } if (ev.proto) { - if (error.name === 'MessageCounterError') { + if (error && error.name === 'MessageCounterError') { if (ev.confirm) { ev.confirm(); } @@ -870,7 +871,7 @@ const envelope = ev.proto; const message = initIncomingMessage(envelope); - await message.saveErrors(error); + await message.saveErrors(error || new Error('Error was null')); const id = message.get('conversationId'); const conversation = await ConversationController.getOrCreateAndWait( id, diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index 0d63a78b8d63..f56ca963d602 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -503,7 +503,7 @@ MessageReceiver.prototype.extend({ .catch(error => { let errorToThrow = error; - if (error.message === 'Unknown identity key') { + if (error && error.message === 'Unknown identity key') { // create an error that the UI will pick up and ask the // user if they want to re-negotiate const buffer = dcodeIO.ByteBuffer.wrap(ciphertext);