put a message in container node when config file is not found

This commit is contained in:
Bruno Windels 2022-05-18 21:41:31 +02:00
parent 0e46aed0df
commit 1555b0f4bc

View file

@ -169,22 +169,32 @@ export class Platform {
} }
async init() { async init() {
await this.logger.run("Platform init", async (log) => { try {
if (!this._config) { await this.logger.run("Platform init", async (log) => {
if (!this._configURL) { if (!this._config) {
throw new Error("Neither config nor configURL was provided!"); if (!this._configURL) {
throw new Error("Neither config nor configURL was provided!");
}
const {status, body}= await this.request(this._configURL, {method: "GET", format: "json", cache: true}).response();
if (status === 404) {
throw new Error(`Could not find ${this._configURL}. Did you copy over config.sample.json?`);
} else if (status >= 400) {
throw new Error(`Got status ${status} while trying to fetch ${this._configURL}`);
}
this._config = body;
} }
const {body}= await this.request(this._configURL, {method: "GET", format: "json", cache: true}).response(); this.notificationService = new NotificationService(
this._config = body; this._serviceWorkerHandler,
} this._config.push
this.notificationService = new NotificationService( );
this._serviceWorkerHandler, const manifests = this.config["themeManifests"];
this._config.push await this._themeLoader?.init(manifests);
); this._themeLoader?.setTheme(await this._themeLoader.getActiveTheme(), log);
const manifests = this.config["themeManifests"]; });
await this._themeLoader?.init(manifests); } catch (err) {
this._themeLoader?.setTheme(await this._themeLoader.getActiveTheme(), log); this._container.innerText = err.message;
}); throw err;
}
} }
_createLogger(isDevelopment) { _createLogger(isDevelopment) {