summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/js/core.js13
-rw-r--r--ext/js/templates/sandbox/template-renderer-frame-api.js9
-rw-r--r--test/test-anki-note-builder.js9
3 files changed, 21 insertions, 10 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;
}
diff --git a/ext/js/templates/sandbox/template-renderer-frame-api.js b/ext/js/templates/sandbox/template-renderer-frame-api.js
index f234c8e0..af83425b 100644
--- a/ext/js/templates/sandbox/template-renderer-frame-api.js
+++ b/ext/js/templates/sandbox/template-renderer-frame-api.js
@@ -72,12 +72,15 @@ class TemplateRendererFrameApi {
_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
diff --git a/test/test-anki-note-builder.js b/test/test-anki-note-builder.js
index 45087134..2e4beb21 100644
--- a/test/test-anki-note-builder.js
+++ b/test/test-anki-note-builder.js
@@ -92,12 +92,15 @@ async function createVM() {
_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