mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Throw error from outside log method
This will show the error in the UI
This commit is contained in:
parent
7590c55404
commit
6335da0932
@ -333,8 +333,8 @@ export class Platform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async replaceStylesheet(newPath, log) {
|
async replaceStylesheet(newPath, log) {
|
||||||
await this.logger.wrapOrRun(log, { l: "replaceStylesheet", location: newPath, }, async (l) => {
|
const error = await this.logger.wrapOrRun(log, { l: "replaceStylesheet", location: newPath, }, async (l) => {
|
||||||
let resolve;
|
let resolve, error;
|
||||||
const promise = new Promise(r => resolve = r);
|
const promise = new Promise(r => resolve = r);
|
||||||
const head = document.querySelector("head");
|
const head = document.querySelector("head");
|
||||||
// remove default theme
|
// remove default theme
|
||||||
@ -346,17 +346,20 @@ export class Platform {
|
|||||||
styleTag.type = "text/css";
|
styleTag.type = "text/css";
|
||||||
styleTag.className = "theme";
|
styleTag.className = "theme";
|
||||||
styleTag.onerror = () => {
|
styleTag.onerror = () => {
|
||||||
const error = new Error(`Failed to load stylesheet at ${newPath}`);
|
error = new Error(`Failed to load stylesheet from ${newPath}`);
|
||||||
l.catch(error);
|
l.catch(error);
|
||||||
resolve();
|
resolve();
|
||||||
throw error
|
|
||||||
};
|
};
|
||||||
styleTag.onload = () => {
|
styleTag.onload = () => {
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
head.appendChild(styleTag);
|
head.appendChild(styleTag);
|
||||||
await promise;
|
await promise;
|
||||||
|
return error;
|
||||||
});
|
});
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get description() {
|
get description() {
|
||||||
|
Loading…
Reference in New Issue
Block a user