From eaae6ff197a877a3630a55ce03aeb6f766e65d6d Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 24 Oct 2017 16:36:54 -0700 Subject: [PATCH] Ensure error codes are displayed and db migrate runs synchronously --- app/src/browser/application.es6 | 23 +++++++++++------------ app/src/mailsync-process.es6 | 5 +++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/browser/application.es6 b/app/src/browser/application.es6 index 4d28e355a..a17707ba2 100644 --- a/app/src/browser/application.es6 +++ b/app/src/browser/application.es6 @@ -47,17 +47,6 @@ export default class Application extends EventEmitter { const mailsync = new MailsyncProcess(options, null); await mailsync.migrate(); } catch (err) { - const callback = buttonIndex => { - if (buttonIndex === 0) { - app.quit(); - } else { - this._deleteDatabase(() => { - app.relaunch(); - app.quit(); - }); - } - }; - let message = null; let buttons = ['Quit']; if (err.toString().includes('ENOENT')) { @@ -69,7 +58,17 @@ export default class Application extends EventEmitter { buttons = ['Quit', 'Rebuild']; } - dialog.showMessageBox({ type: 'warning', buttons, message }, callback); + const buttonIndex = dialog.showMessageBox({ type: 'warning', buttons, message }); + + if (buttonIndex === 0) { + app.quit(); + } else { + this._deleteDatabase(() => { + app.relaunch(); + app.quit(); + }); + } + return; } const Config = require('../config'); diff --git a/app/src/mailsync-process.es6 b/app/src/mailsync-process.es6 index 81fde7031..d669f070e 100644 --- a/app/src/mailsync-process.es6 +++ b/app/src/mailsync-process.es6 @@ -103,7 +103,8 @@ export default class MailsyncProcess extends EventEmitter { this._proc.on('close', code => { const stripSecrets = text => { - const { refresh_token, imap_password, smtp_password } = this.account.settings; + const settings = (this.account && this.account.settings) || {}; + const { refresh_token, imap_password, smtp_password } = settings; return (text || '') .replace(new RegExp(refresh_token || 'not-present', 'g'), '*********') .replace(new RegExp(imap_password || 'not-present', 'g'), '*********') @@ -128,7 +129,7 @@ export default class MailsyncProcess extends EventEmitter { reject(error); } } catch (err) { - const error = new Error('An unexpected error occurred - view the raw log for details.'); + const error = new Error(`An unexpected mailsync error occurred (${code})`); error.rawLog = stripSecrets(buffer.toString()); reject(error); }