From 0cadb8338373e6f1fe42131d5b0a76c533ee7b48 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 30 Mar 2022 06:44:03 +1100 Subject: [PATCH 1/2] fix(web): track load error detail This is a follow-up for #6331. We still did not have enough detail to be able to trace the root cause of the load errors. This adds a little more diagnostics. --- web/source/keyboards/kmwkeyboards.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/web/source/keyboards/kmwkeyboards.ts b/web/source/keyboards/kmwkeyboards.ts index 3fa42de125..e62f78b363 100644 --- a/web/source/keyboards/kmwkeyboards.ts +++ b/web/source/keyboards/kmwkeyboards.ts @@ -484,7 +484,7 @@ namespace com.keyman.keyboards { // // In case p's rejection is never caught, throwing this error will generate logs that shows up // in Sentry or in the console, with useful information for debugging either way. - throw new Error("Unable to load keyboard with internal name \"" + PInternalName + "\", language code \"" + PLgCode + "\": "+JSON.stringify(error)); + throw new Error("Unable to load keyboard with internal name \"" + PInternalName + "\", language code \"" + PLgCode + "\": " + error); }); return p; @@ -700,7 +700,7 @@ namespace com.keyman.keyboards { * @param {Object} kbdStub keyboard stub to be loaded. * **/ - installKeyboard(resolve: () => void, reject: () => void, kbdStub: KeyboardStub) { + installKeyboard(resolve: () => void, reject: (message?: string) => void, kbdStub: KeyboardStub) { var util = this.keymanweb.util; var osk = this.keymanweb.osk; @@ -717,6 +717,8 @@ namespace com.keyman.keyboards { var kbdLang = kbdStub['KL']; var kbdName = kbdStub['KN']; + const scriptSrc = this.keymanweb.getKeyboardPath(kbdFile); + var manager = this; let core = com.keyman.singleton.core; @@ -729,15 +731,16 @@ namespace com.keyman.keyboards { } // We already know the load has failed... why wait? - kbdStub.asyncLoader.callback('Cannot find the ' + kbdName + ' keyboard for ' + kbdLang + '.', 'warn'); + const msg = 'Cannot find the ' + kbdName + ' keyboard for ' + kbdLang + ' at ' + scriptSrc + '.'; + kbdStub.asyncLoader.callback(msg, 'warn'); kbdStub.asyncLoader = null; - reject(); - }, false); + reject(msg); + }); // The load event will activate a newly-loaded keyboard if successful and report an error if it is not. - Lscript.addEventListener('load', function() { + Lscript.addEventListener('load', function(ev) { if(kbdStub.asyncLoader.timer !== null) { // Clear the timeout timer. window.clearTimeout(kbdStub.asyncLoader.timer); @@ -780,27 +783,29 @@ namespace com.keyman.keyboards { resolve(); // A handler portion for cases where the new