refactor: take advantage of structured clone algorithm in the remote module (#20427)

This commit is contained in:
Milan Burda 2019-10-10 15:59:08 +02:00 committed by John Kleinschmidt
parent c2e77e4429
commit b92163d226
13 changed files with 87 additions and 210 deletions

View file

@ -1,5 +1,4 @@
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'
import * as errorUtils from '@electron/internal/common/error-utils'
type IPCHandler = (event: Electron.IpcRendererEvent, ...args: any[]) => any
@ -9,7 +8,7 @@ export const handle = function <T extends IPCHandler> (channel: string, handler:
try {
event.sender.send(replyChannel, null, await handler(event, ...args))
} catch (error) {
event.sender.send(replyChannel, errorUtils.serialize(error))
event.sender.send(replyChannel, error)
}
})
}
@ -18,7 +17,7 @@ export function invokeSync<T> (command: string, ...args: any[]): T {
const [ error, result ] = ipcRendererInternal.sendSync(command, ...args)
if (error) {
throw errorUtils.deserialize(error)
throw error
} else {
return result
}