summaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-21 19:08:56 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-21 19:08:56 -0500
commit26ea278c29dbb19d003dddda2e60559c502d0cc3 (patch)
treeb13a72cd9926f37c27c8bec8dfb4ccf5d7fe85a4 /ext/mixed
parent1fd568ab8e7c909010e843654540162baeab9e1e (diff)
Improve debug logging
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/core.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 54e8a9d2..7fc01c94 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -56,7 +56,8 @@ function errorToJson(error) {
return {
name: error.name,
message: error.message,
- stack: error.stack
+ stack: error.stack,
+ data: error.data
};
}
@@ -64,6 +65,7 @@ function jsonToError(jsonError) {
const error = new Error(jsonError.message);
error.name = jsonError.name;
error.stack = jsonError.stack;
+ error.data = jsonError.data;
return error;
}
@@ -74,7 +76,11 @@ function logError(error, alert) {
const errorString = `${error.toString ? error.toString() : error}`;
const stack = `${error.stack}`.trimRight();
- errorMessage += (!stack.startsWith(errorString) ? `${errorString}\n${stack}` : `${stack}`);
+ if (!stack.startsWith(errorString)) { errorMessage += `${errorString}\n`; }
+ errorMessage += stack;
+
+ const data = error.data;
+ if (typeof data !== 'undefined') { errorMessage += `\nData: ${JSON.stringify(data, null, 4)}`; }
errorMessage += '\n\nIssues can be reported at https://github.com/FooSoft/yomichan/issues';