aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-26 16:55:25 -0400
committerGitHub <noreply@github.com>2020-04-26 16:55:25 -0400
commit5b96559df819f496b39acb75c679f6b3d8c8e65d (patch)
tree95af8543c642f4ddc30982526e022967aac49742 /ext/fg
parentca033a87a0d302151b430acfdf9d480514c14aed (diff)
Error logging refactoring (#454)
* Create new logging methods on yomichan object * Use new yomichan.logError instead of global logError * Remove old logError * Handle unhandledrejection events * Add addEventListener stub * Update log function * Update error conversion to support more types * Add log event * Add API log function * Log errors to the backend * Make error/warning logs update the badge * Clear log error indicator on extension button click * Log correct URL on the background page * Fix incorrect error conversion * Remove unhandledrejection handling Firefox doesn't support it properly. * Remove unused argument type from log function * Improve function name * Change console.warn to yomichan.logWarning * Move log forwarding initialization into main scripts
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/content-script-main.js2
-rw-r--r--ext/fg/js/float-main.js2
-rw-r--r--ext/fg/js/float.js2
-rw-r--r--ext/fg/js/frontend-api-sender.js8
-rw-r--r--ext/fg/js/popup-proxy.js2
5 files changed, 10 insertions, 6 deletions
diff --git a/ext/fg/js/content-script-main.js b/ext/fg/js/content-script-main.js
index 0b852644..277e6567 100644
--- a/ext/fg/js/content-script-main.js
+++ b/ext/fg/js/content-script-main.js
@@ -22,6 +22,7 @@
* PopupProxy
* PopupProxyHost
* apiBroadcastTab
+ * apiForwardLogsToBackend
* apiOptionsGet
*/
@@ -62,6 +63,7 @@ async function createPopupProxy(depth, id, parentFrameId) {
}
(async () => {
+ apiForwardLogsToBackend();
await yomichan.prepare();
const data = window.frontendInitializationData || {};
diff --git a/ext/fg/js/float-main.js b/ext/fg/js/float-main.js
index f056f707..5ef4b07c 100644
--- a/ext/fg/js/float-main.js
+++ b/ext/fg/js/float-main.js
@@ -17,6 +17,7 @@
/* global
* DisplayFloat
+ * apiForwardLogsToBackend
* apiOptionsGet
*/
@@ -68,5 +69,6 @@ async function popupNestedInitialize(id, depth, parentFrameId, url) {
}
(async () => {
+ apiForwardLogsToBackend();
new DisplayFloat();
})();
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index 2a5eba83..fd3b92cc 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -84,7 +84,7 @@ class DisplayFloat extends Display {
if (this._orphaned) {
this.setContent('orphaned');
} else {
- logError(error, true);
+ yomichan.logError(error);
}
}
diff --git a/ext/fg/js/frontend-api-sender.js b/ext/fg/js/frontend-api-sender.js
index 1d539cab..0ad3f085 100644
--- a/ext/fg/js/frontend-api-sender.js
+++ b/ext/fg/js/frontend-api-sender.js
@@ -81,12 +81,12 @@ class FrontendApiSender {
onAck(id) {
const info = this.callbacks.get(id);
if (typeof info === 'undefined') {
- console.warn(`ID ${id} not found for ack`);
+ yomichan.logWarning(new Error(`ID ${id} not found for ack`));
return;
}
if (info.ack) {
- console.warn(`Request ${id} already ack'd`);
+ yomichan.logWarning(new Error(`Request ${id} already ack'd`));
return;
}
@@ -98,12 +98,12 @@ class FrontendApiSender {
onResult(id, data) {
const info = this.callbacks.get(id);
if (typeof info === 'undefined') {
- console.warn(`ID ${id} not found`);
+ yomichan.logWarning(new Error(`ID ${id} not found`));
return;
}
if (!info.ack) {
- console.warn(`Request ${id} not ack'd`);
+ yomichan.logWarning(new Error(`Request ${id} not ack'd`));
return;
}
diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js
index cd3c1bc9..93418202 100644
--- a/ext/fg/js/popup-proxy.js
+++ b/ext/fg/js/popup-proxy.js
@@ -148,7 +148,7 @@ class PopupProxy {
}
this._frameOffsetUpdatedAt = now;
} catch (e) {
- logError(e);
+ yomichan.logError(e);
} finally {
this._frameOffsetPromise = null;
}