[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Show main process unhandled errors to user

Kasper (Apr 6, 2021, 2:03 AM +0200) ddc332f7 e27c5ce9

+22 -1
+22 -1
src/electron.js
··· 1 - const { app, ipcMain, session, BrowserWindow, protocol } = require('electron') 1 + const { app, ipcMain, session, BrowserWindow, dialog, protocol } = require('electron') 2 2 const is = require('./electron/is.js') 3 3 const fs = require('fs').promises 4 4 if (is.dev) app.setName('Ferrum Dev') ··· 8 8 const ipc = require('./electron/ipc.js') 9 9 const path = require('path') 10 10 const vars = require('./variables.json') 11 + 12 + async function errHandler(msg, error) { 13 + if (app.isReady()) { 14 + dialog.showMessageBoxSync({ 15 + type: 'error', 16 + message: msg, 17 + detail: error.stack, 18 + title: 'Error', 19 + }) 20 + } else { 21 + app.on('msg, error', () => { 22 + errHandler(msg, error) 23 + }) 24 + } 25 + } 26 + process.on('uncaughtException', (error) => { 27 + errHandler('Unhandled Error', error) 28 + }) 29 + process.on('unhandledRejection', (error) => { 30 + errHandler('Unhandled Promise Rejection', error) 31 + }) 11 32 12 33 const appData = app.getPath('appData') 13 34 const electronDataPath = path.join(appData, app.name, 'Electron Data')