refactor: use error-utils for remote exception serialization / deserialization (#14788)
* refactor: use error-utils for remote exception serialization / deserialization * fix internal process.type in sandboxed renderer
This commit is contained in:
parent
3df739fa89
commit
b499d57cfd
4 changed files with 19 additions and 20 deletions
|
@ -6,6 +6,7 @@ const resolvePromise = Promise.resolve.bind(Promise)
|
|||
|
||||
const CallbacksRegistry = require('@electron/internal/renderer/callbacks-registry')
|
||||
const bufferUtils = require('@electron/internal/common/buffer-utils')
|
||||
const errorUtils = require('@electron/internal/common/error-utils')
|
||||
|
||||
const callbacksRegistry = new CallbacksRegistry()
|
||||
const remoteObjectCache = v8Util.createIDWeakMap()
|
||||
|
@ -217,7 +218,7 @@ function metaToValue (meta) {
|
|||
promise: () => resolvePromise({ then: metaToValue(meta.then) }),
|
||||
error: () => metaToPlainObject(meta),
|
||||
date: () => new Date(meta.value),
|
||||
exception: () => { throw metaToException(meta) }
|
||||
exception: () => { throw errorUtils.deserialize(meta.value) }
|
||||
}
|
||||
|
||||
if (meta.type in types) {
|
||||
|
@ -267,15 +268,6 @@ function metaToPlainObject (meta) {
|
|||
return obj
|
||||
}
|
||||
|
||||
// Construct an exception error from the meta.
|
||||
function metaToException (meta) {
|
||||
const error = new Error(`${meta.message}\n${meta.stack}`)
|
||||
const remoteProcess = exports.process
|
||||
error.from = remoteProcess ? remoteProcess.type : null
|
||||
error.cause = metaToValue(meta.cause)
|
||||
return error
|
||||
}
|
||||
|
||||
function handleMessage (channel, handler) {
|
||||
ipcRenderer.on(channel, (event, passedContextId, ...args) => {
|
||||
if (passedContextId === contextId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue