Catch an errors in ElectronJS

10 Views Asked by At

Good afternoon!

How to intercept an error(s) in the main process of the ElectronJS application with sqllite3? It seems that the try-catch construction does not work in the "standard way" in Electron apps.

preload.js

deleteMainMenuItem: (id) => ipcRenderer.invoke("delete-main-menu-item", id)

main.js

ipcMain.handle("delete-main-menu-item", (event, id) => {
  try {
    db.run("DELETE FROM projects_ErrOrNaMe WHERE id=?", [id]); //here error occured
  } catch (error) {
    console.log(error); //this code is never works
  }
});

At the same time, a standard error window show out on top of an application like this. How to intercept? enter image description here

Does electron have a different principle of working with errors, or am I being stupid somewhere? Thanks!

0

There are 0 best solutions below