Make executeJavaScript return a Promise so that caught errors can be sent to the caller

This commit is contained in:
Samuel Attard 2016-10-11 16:47:09 +11:00 committed by Kevin Sawicki
parent 75b010ce63
commit 857e1da6a3
5 changed files with 59 additions and 7 deletions

View file

@ -173,6 +173,10 @@ app.on('ready', function () {
if (hasCallback) {
window.webContents.executeJavaScript(code, (result) => {
window.webContents.send('executeJavaScript-response', result)
}).then((result) => {
window.webContents.send('executeJavaScript-promise-response', result)
}).catch((err) => {
window.webContents.send('executeJavaScript-promise-error', err)
})
} else {
window.webContents.executeJavaScript(code)