Be resilient to null thrown errors so we can surface to user

This commit is contained in:
Scott Nonnenberg 2018-07-13 08:59:18 -07:00
parent c54ba8d1fa
commit f5852bb357
2 changed files with 5 additions and 4 deletions

View file

@ -819,6 +819,7 @@
console.log('background onError:', Errors.toLogFormat(error)); console.log('background onError:', Errors.toLogFormat(error));
if ( if (
error &&
error.name === 'HTTPError' && error.name === 'HTTPError' &&
(error.code === 401 || error.code === 403) (error.code === 401 || error.code === 403)
) { ) {
@ -847,7 +848,7 @@
return; return;
} }
if (error.name === 'HTTPError' && error.code === -1) { if (error && error.name === 'HTTPError' && error.code === -1) {
// Failed to connect to server // Failed to connect to server
if (navigator.onLine) { if (navigator.onLine) {
console.log('retrying in 1 minute'); console.log('retrying in 1 minute');
@ -859,7 +860,7 @@
} }
if (ev.proto) { if (ev.proto) {
if (error.name === 'MessageCounterError') { if (error && error.name === 'MessageCounterError') {
if (ev.confirm) { if (ev.confirm) {
ev.confirm(); ev.confirm();
} }
@ -870,7 +871,7 @@
const envelope = ev.proto; const envelope = ev.proto;
const message = initIncomingMessage(envelope); const message = initIncomingMessage(envelope);
await message.saveErrors(error); await message.saveErrors(error || new Error('Error was null'));
const id = message.get('conversationId'); const id = message.get('conversationId');
const conversation = await ConversationController.getOrCreateAndWait( const conversation = await ConversationController.getOrCreateAndWait(
id, id,

View file

@ -503,7 +503,7 @@ MessageReceiver.prototype.extend({
.catch(error => { .catch(error => {
let errorToThrow = 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 // create an error that the UI will pick up and ask the
// user if they want to re-negotiate // user if they want to re-negotiate
const buffer = dcodeIO.ByteBuffer.wrap(ciphertext); const buffer = dcodeIO.ByteBuffer.wrap(ciphertext);