Write a warning instead of crashing.
This commit is contained in:
parent
bc2f1e8199
commit
c213971a2d
3 changed files with 15 additions and 10 deletions
|
@ -251,11 +251,13 @@ ipcMain.on('prevent-next-new-window', (event, id) => {
|
|||
})
|
||||
|
||||
ipcMain.on('try-emit-web-contents-event', (event, id, eventName) => {
|
||||
const contents = webContents.fromId(id)
|
||||
try {
|
||||
contents.emit(eventName, {sender: contents})
|
||||
event.returnValue = null
|
||||
} catch (error) {
|
||||
event.returnValue = error.message
|
||||
const consoleWarn = console.warn
|
||||
let lastWarning = null
|
||||
console.warn = (message) => {
|
||||
lastWarning = message
|
||||
}
|
||||
const contents = webContents.fromId(id)
|
||||
contents.emit(eventName, {sender: contents})
|
||||
event.returnValue = lastWarning
|
||||
console.warn = consoleWarn
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue