Main-process errors (window.Electron.onElectronError)
Forwards uncaught main-process failures to the renderer, so a crash in electron/main.ts or a module you added isn't invisible to your app. Source: src/main/process-guardian.ts, channel electronError. Always on, no config needed — installed once via setupProcessGuardian(), which createElectronApp() calls before app.whenReady().
This is distinct from Crash reporter, which captures native process-level crash dumps (segfaults, renderer crashes) via Electron's crashReporter/safeStorage machinery — this module catches JS-level uncaughtException/unhandledRejection in the main process specifically.
Method
| Method | Returns | Notes |
|---|---|---|
onElectronError(callback: (data: { message: string; stack: string | undefined; type: 'exception' | 'rejection' }) => void) |
() => void (unsubscribe) |
Broadcast to every open window. Not part of .safe (event subscription, never throws). |
type: 'exception' is an uncaught synchronous exception (process.setUncaughtExceptionCaptureCallback); type: 'rejection' is an unhandled Promise rejection (process.on('unhandledRejection')). Both are also logged to the main process's own console regardless of whether anything is listening on the renderer side.
Example
const unsubscribe = window.Electron.onElectronError(({ type, message, stack }) => {
console.error(`[main process ${type}]`, message, stack);
// e.g. report to your own error tracker, or show a non-blocking toast
});
.safe
None — onElectronError is a pure event subscription and has no .safe counterpart.