fix: add WASM init error handling to index page
This commit is contained in:
@@ -85,7 +85,10 @@ async function checkAuth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function initApp() {
|
async function initApp() {
|
||||||
|
const el = document.getElementById('content');
|
||||||
|
try {
|
||||||
await init();
|
await init();
|
||||||
|
el.innerHTML = '<p>WASM initialized. Loading modules...</p>';
|
||||||
|
|
||||||
// Parse module list
|
// Parse module list
|
||||||
modules = JSON.parse(module_list());
|
modules = JSON.parse(module_list());
|
||||||
@@ -113,6 +116,9 @@ async function initApp() {
|
|||||||
} else {
|
} else {
|
||||||
loadDoc('01_auth');
|
loadDoc('01_auth');
|
||||||
}
|
}
|
||||||
|
} catch(e) {
|
||||||
|
el.innerHTML = `<p style="color:red">WASM init error: ${e.message}</p><pre>${e.stack}</pre>`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle browser back/forward
|
// Handle browser back/forward
|
||||||
@@ -121,6 +127,7 @@ window.onpopstate = () => {
|
|||||||
if (hash) loadDoc(hash);
|
if (hash) loadDoc(hash);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
document.getElementById('content').innerHTML = '<p>Starting WASM...</p>';
|
||||||
initApp();
|
initApp();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user