mirror of
https://github.com/electron/electron.git
synced 2026-01-29 01:08:18 -05:00
* refactor: add error-utils.js
* fix exception handling for asyncWebFrameMethods
* remove dead code
* handle exceptions
* rename rehydratedError to deserializedError
* Revert "handle exceptions"
This reverts commit 396b179948.
22 lines
723 B
JavaScript
22 lines
723 B
JavaScript
const {ipcRenderer, webFrame} = require('electron')
|
|
const errorUtils = require('../common/error-utils')
|
|
|
|
module.exports = () => {
|
|
// Call webFrame method
|
|
ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', (event, method, args) => {
|
|
webFrame[method](...args)
|
|
})
|
|
|
|
ipcRenderer.on('ELECTRON_INTERNAL_RENDERER_ASYNC_WEB_FRAME_METHOD', (event, requestId, method, args) => {
|
|
new Promise(resolve =>
|
|
webFrame[method](...args, resolve)
|
|
).then(result => {
|
|
return [null, result]
|
|
}, error => {
|
|
return [errorUtils.serialize(error)]
|
|
}).then(responseArgs => {
|
|
event.sender.send(`ELECTRON_INTERNAL_BROWSER_ASYNC_WEB_FRAME_RESPONSE_${requestId}`, ...responseArgs)
|
|
})
|
|
})
|
|
}
|