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
|
@ -11,10 +11,12 @@ const constructors = new Map([
|
|||
])
|
||||
|
||||
exports.deserialize = function (error) {
|
||||
if (error.__ELECTRON_SERIALIZED_ERROR__ && constructors.has(error.name)) {
|
||||
if (error && error.__ELECTRON_SERIALIZED_ERROR__ && constructors.has(error.name)) {
|
||||
const constructor = constructors.get(error.name)
|
||||
const deserializedError = new constructor(error.message)
|
||||
deserializedError.stack = error.stack
|
||||
deserializedError.from = error.from
|
||||
deserializedError.cause = exports.deserialize(error.cause)
|
||||
return deserializedError
|
||||
}
|
||||
return error
|
||||
|
@ -28,6 +30,8 @@ exports.serialize = function (error) {
|
|||
message: error.message,
|
||||
stack: error.stack,
|
||||
name: error.name,
|
||||
from: process.type,
|
||||
cause: exports.serialize(error.cause),
|
||||
__ELECTRON_SERIALIZED_ERROR__: true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue