mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Electron: Log uncaught exceptions in main process
This commit is contained in:
parent
b24b3f0c55
commit
ac9b02c2d8
1 changed files with 6 additions and 5 deletions
|
@ -10,7 +10,6 @@ import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
import { hideBin } from 'yargs/helpers';
|
import { hideBin } from 'yargs/helpers';
|
||||||
import { ToastIcon } from 'common/components/Toast';
|
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
let logger = null;
|
let logger = null;
|
||||||
|
|
||||||
|
@ -389,6 +388,8 @@ export class Main {
|
||||||
logger.info(`Release channel: ${Updater.releaseChannel} - ${Updater.getChannelVersion()}`);
|
logger.info(`Release channel: ${Updater.releaseChannel} - ${Updater.getChannelVersion()}`);
|
||||||
logger.info(`OS: ${process.platform} ${process.arch}`);
|
logger.info(`OS: ${process.platform} ${process.arch}`);
|
||||||
|
|
||||||
|
process.setUncaughtExceptionCaptureCallback(async (error) => await errorHandler(error));
|
||||||
|
|
||||||
if (isUpdating) {
|
if (isUpdating) {
|
||||||
await Updater.processUpdate();
|
await Updater.processUpdate();
|
||||||
}
|
}
|
||||||
|
@ -458,14 +459,14 @@ export function getComputerName() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function errorHandler(err: NodeJS.ErrnoException) {
|
export async function errorHandler(error: Error) {
|
||||||
logger.error("Application error:", err);
|
logger.error(error);
|
||||||
Main.mainWindow?.webContents?.send("toast", { message: err, icon: ToastIcon.ERROR });
|
logger.shutdown();
|
||||||
|
|
||||||
const restartPrompt = await dialog.showMessageBox({
|
const restartPrompt = await dialog.showMessageBox({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
title: 'Failed to start',
|
title: 'Failed to start',
|
||||||
message: 'The application failed to start properly.',
|
message: `The application failed to start properly:\n\n${error.stack}}`,
|
||||||
buttons: ['Restart', 'Close'],
|
buttons: ['Restart', 'Close'],
|
||||||
defaultId: 0,
|
defaultId: 0,
|
||||||
cancelId: 1
|
cancelId: 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue