Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7190

Electron handle crashes gracefully

$
0
0

I'm trying to implement libp2p inside an electron application, which (obviously) has node support turned on.

I tried catching errors with the following code:

const errorHandle = `window.onerror = (err) => {    console.log(err);};process.on("uncaughtException", function (err) {    console.log(err);});process.on("unhandledRejection", function (err) {    console.log(err);});console.log("Injected startup code")`await mainWindow.loadFile("./public/index.html");await mainWindow.webContents.executeJavaScript(errorHandle);

However if I throw an error deliberately, or by accident, the app crashes, and gets reloaded, and I can't see the error, because chrome devtools clears its console, and prints out the "Devtools disconnected" message.

2 examples of error throwing:

console.error("test");node.connect("INVALID_ADDRESS");

How can I properly handle errors, so electron (or node) doesn't crash?


Viewing all articles
Browse latest Browse all 7190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>