You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-13 22:12:50 +02:00
All: Better handling of startup errors
This commit is contained in:
@@ -87,6 +87,13 @@ process.stdout.on('error', function( err ) {
|
||||
|
||||
|
||||
application.start(process.argv).catch((error) => {
|
||||
console.error(_('Fatal error:'));
|
||||
console.error(error);
|
||||
if (error.code == 'flagError') {
|
||||
console.error(error.message);
|
||||
console.error(_('Type `joplin help` for usage information.'));
|
||||
} else {
|
||||
console.error(_('Fatal error:'));
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
});
|
@@ -110,10 +110,14 @@ class ElectronAppWrapper {
|
||||
});
|
||||
}
|
||||
|
||||
async exit() {
|
||||
async quit() {
|
||||
this.electronApp_.quit();
|
||||
}
|
||||
|
||||
exit(errorCode = 0) {
|
||||
this.electronApp_.exit(errorCode);
|
||||
}
|
||||
|
||||
trayShown() {
|
||||
return !!this.tray_;
|
||||
}
|
||||
|
@@ -342,7 +342,7 @@ class Application extends BaseApplication {
|
||||
}, {
|
||||
label: _('Quit'),
|
||||
accelerator: 'CommandOrControl+Q',
|
||||
click: () => { bridge().electronApp().exit() }
|
||||
click: () => { bridge().electronApp().quit() }
|
||||
}]
|
||||
}, {
|
||||
label: _('Edit'),
|
||||
@@ -518,7 +518,7 @@ class Application extends BaseApplication {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: _('Open %s', app.electronApp().getName()), click: () => { app.window().show(); } },
|
||||
{ type: 'separator' },
|
||||
{ label: _('Exit'), click: () => { app.exit() } },
|
||||
{ label: _('Exit'), click: () => { app.quit() } },
|
||||
])
|
||||
app.createTray(contextMenu);
|
||||
}
|
||||
|
@@ -64,11 +64,17 @@ document.addEventListener('click', (event) => event.preventDefault());
|
||||
app().start(bridge().processArgv()).then(() => {
|
||||
require('./gui/Root.min.js');
|
||||
}).catch((error) => {
|
||||
// If something goes wrong at this stage we don't have a console or a log file
|
||||
// so display the error in a message box.
|
||||
let msg = ['Fatal error:', error.message];
|
||||
if (error.fileName) msg.push(error.fileName);
|
||||
if (error.lineNumber) msg.push(error.lineNumber);
|
||||
if (error.stack) msg.push(error.stack);
|
||||
bridge().showErrorMessageBox(msg.join('\n'));
|
||||
if (error.code == 'flagError') {
|
||||
bridge().showErrorMessageBox(error.message);
|
||||
} else {
|
||||
// If something goes wrong at this stage we don't have a console or a log file
|
||||
// so display the error in a message box.
|
||||
let msg = ['Fatal error:', error.message];
|
||||
if (error.fileName) msg.push(error.fileName);
|
||||
if (error.lineNumber) msg.push(error.lineNumber);
|
||||
if (error.stack) msg.push(error.stack);
|
||||
bridge().showErrorMessageBox(msg.join('\n'));
|
||||
}
|
||||
|
||||
bridge().electronApp().exit(1);
|
||||
});
|
@@ -359,18 +359,7 @@ class BaseApplication {
|
||||
}
|
||||
|
||||
async start(argv) {
|
||||
let startFlags = null;
|
||||
|
||||
try {
|
||||
startFlags = await this.handleStartFlags_(argv);
|
||||
} catch (error) {
|
||||
if (error.code == 'flagError') {
|
||||
console.info(error.message);
|
||||
console.info(_('Type `joplin help` for usage information.'));
|
||||
process.exit(1);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
let startFlags = await this.handleStartFlags_(argv);
|
||||
|
||||
argv = startFlags.argv;
|
||||
let initArgs = startFlags.matched;
|
||||
|
Reference in New Issue
Block a user