From 7eddd20a01f0b75cd2a51f380929189d8eced240 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 31 Jan 2022 19:16:50 +0100 Subject: [PATCH] index.html: catch and display errors --- docs/index.html | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/index.html b/docs/index.html index 47975923..c8f66fba 100644 --- a/docs/index.html +++ b/docs/index.html @@ -46,7 +46,7 @@ transform: translate(-50%, 0%); } - .loading { + .centered { margin-right: auto; margin-left: auto; display: block; @@ -54,9 +54,10 @@ top: 50%; left: 50%; transform: translate(-50%, -50%); - color: white; + color: #f0f0f0; font-size: 24px; font-family: Ubuntu-Light, Helvetica, sans-serif; + text-align: center; } /* ---------------------------------------------- */ @@ -94,8 +95,10 @@ -
- Loading…   +
+

+ Loading… +

@@ -121,7 +124,7 @@ // initialization and return to us a promise when it's done. wasm_bindgen("./egui_demo_app_bg.wasm") .then(on_wasm_loaded) - .catch(console.error); + .catch(on_wasm_error); function on_wasm_loaded() { console.log("loaded wasm, starting egui app…"); @@ -130,7 +133,21 @@ wasm_bindgen.start("the_canvas_id"); console.log("egui app started."); - document.getElementById("loading").remove(); + document.getElementById("center_text").remove(); + } + + function on_wasm_error(error) { + console.error("Failed to start egui: " + error); + document.getElementById("center_text").innerHTML = ` +

+ An error occurred loading egui +

+

+ ${error} +

+

+ Make sure you use a modern browser with WebGL and WASM enabled. +

`; }