Skip to content

Commit

Permalink
wrap createWindow in try..catch
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Nov 15, 2023
1 parent d9c41ce commit 60e0218
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/altair-electron/src/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { app, BrowserWindow, protocol, session, shell } from 'electron';
import { app, protocol, session, shell, dialog } from 'electron';
import { readFile } from 'fs';
import isDev from 'electron-is-dev';
import { setupAutoUpdates } from '../updates';
import { InMemoryStore } from '../store';
import { WindowManager } from './window';
import { store } from '../settings/main/store';
import { AuthServer } from '../auth/server';
import { IPC_EVENT_NAMES } from '@altairgraphql/electron-interop';
import { log } from '../utils/log';

Expand Down Expand Up @@ -80,7 +79,16 @@ export class ElectronApp {
);
log(proxy, proxyConfig);
}
this.windowManager.createWindow();
try {
this.windowManager.createWindow();
} catch (err) {
log('Error creating window', err);
dialog.showErrorBox(
'Error creating window. Do you know what the issue is? Feel free to create a github issue',
err as any
);
throw err;
}

if (!isDev) {
setupAutoUpdates();
Expand Down Expand Up @@ -135,7 +143,7 @@ export class ElectronApp {
);

app.on('web-contents-created', (event, contents) => {
contents.setWindowOpenHandler(details => {
contents.setWindowOpenHandler((details) => {
try {
log('Opening url', details.url);
// Ask the operating system to open this event's url in the default browser.
Expand Down

0 comments on commit 60e0218

Please sign in to comment.