From 6335da09326d8ab6c95a6bad0a59048c98376bcf Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Mon, 15 Aug 2022 22:52:02 +0530 Subject: [PATCH] Throw error from outside log method This will show the error in the UI --- src/platform/web/Platform.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/platform/web/Platform.js b/src/platform/web/Platform.js index df24418c..3e6de0c3 100644 --- a/src/platform/web/Platform.js +++ b/src/platform/web/Platform.js @@ -333,8 +333,8 @@ export class Platform { } async replaceStylesheet(newPath, log) { - await this.logger.wrapOrRun(log, { l: "replaceStylesheet", location: newPath, }, async (l) => { - let resolve; + const error = await this.logger.wrapOrRun(log, { l: "replaceStylesheet", location: newPath, }, async (l) => { + let resolve, error; const promise = new Promise(r => resolve = r); const head = document.querySelector("head"); // remove default theme @@ -346,17 +346,20 @@ export class Platform { styleTag.type = "text/css"; styleTag.className = "theme"; styleTag.onerror = () => { - const error = new Error(`Failed to load stylesheet at ${newPath}`); + error = new Error(`Failed to load stylesheet from ${newPath}`); l.catch(error); resolve(); - throw error }; styleTag.onload = () => { resolve(); }; head.appendChild(styleTag); await promise; + return error; }); + if (error) { + throw error; + } } get description() {