Ensure error codes are displayed and db migrate runs synchronously

This commit is contained in:
Ben Gotow 2017-10-24 16:36:54 -07:00
parent d0a91bea80
commit eaae6ff197
2 changed files with 14 additions and 14 deletions

View file

@ -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');

View file

@ -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);
}