Fix error handling in mainpage and stats.

This commit is contained in:
Juliusz Chroboczek
2021-05-17 14:43:57 +02:00
parent 91fa693709
commit 781bdf8c74
2 changed files with 14 additions and 5 deletions
+6 -2
View File
@@ -25,10 +25,14 @@ async function listStats() {
let l;
try {
l = await (await fetch('/stats.json')).json();
let r = await fetch('/stats.json');
if(!r.ok)
throw new Error(`${r.status} ${r.statusText}`);
l = await r.json();
} catch(e) {
console.error(e);
l = [];
table.textContent = `Couldn't fetch stats: ${e}`;
return;
}
if(l.length === 0) {