feat: add preload-error event to webContents (#16411)

This commit is contained in:
Milan Burda 2019-01-18 12:03:43 +01:00 committed by Alexey Kuzmin
parent 98d0daa2fd
commit 7d4a1223fd
7 changed files with 112 additions and 7 deletions

View file

@ -147,13 +147,17 @@ if (nodeIntegration) {
})
}
const errorUtils = require('@electron/internal/common/error-utils')
// Load the preload scripts.
for (const preloadScript of preloadScripts) {
try {
require(preloadScript)
} catch (error) {
console.error('Unable to load preload script: ' + preloadScript)
console.error(error.stack || error.message)
console.error(`Unable to load preload script: ${preloadScript}`)
console.error(`${error}`)
ipcRenderer.send('ELECTRON_BROWSER_PRELOAD_ERROR', preloadScript, errorUtils.serialize(error))
}
}