diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-07-25 12:54:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-25 12:54:26 -0400 |
commit | 3f738898743804fa07c449063bf3065af00e5aa2 (patch) | |
tree | 7942d5603796064160d4ab5992b73812914d45e4 /ext/js/core.js | |
parent | 73f06a3fa087af164c54b57b2d92466d689d107e (diff) |
Update de/serializeError functions to only serialize data if present (#1849)
Diffstat (limited to 'ext/js/core.js')
-rw-r--r-- | ext/js/core.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/js/core.js b/ext/js/core.js index 16d81b67..c43d7828 100644 --- a/ext/js/core.js +++ b/ext/js/core.js @@ -23,12 +23,15 @@ function serializeError(error) { try { if (typeof error === 'object' && error !== null) { - return { + const result = { name: error.name, message: error.message, - stack: error.stack, - data: error.data + stack: error.stack }; + if (Object.prototype.hasOwnProperty.call(error, 'data')) { + result.data = error.data; + } + return result; } } catch (e) { // NOP @@ -51,7 +54,9 @@ function deserializeError(serializedError) { const error = new Error(serializedError.message); error.name = serializedError.name; error.stack = serializedError.stack; - error.data = serializedError.data; + if (Object.prototype.hasOwnProperty.call(serializedError, 'data')) { + error.data = serializedError.data; + } return error; } |