Commit 781bdf8c authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Fix error handling in mainpage and stats.

parent 91fa6937
...@@ -33,10 +33,15 @@ async function listPublicGroups() { ...@@ -33,10 +33,15 @@ async function listPublicGroups() {
let l; let l;
try { try {
l = await (await fetch('/public-groups.json')).json(); let r = await fetch('/public-groups.json');
if(!r.ok)
throw new Error(`${r.status} ${r.statusText}`);
l = await r.json();
} catch(e) { } catch(e) {
console.error(e); table.textContent = `Couldn't fetch groups: ${e}`;
l = []; div.classList.remove('nogroups');
div.classList.add('groups');
return;
} }
if (l.length === 0) { if (l.length === 0) {
......
...@@ -25,10 +25,14 @@ async function listStats() { ...@@ -25,10 +25,14 @@ async function listStats() {
let l; let l;
try { 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) { } catch(e) {
console.error(e); console.error(e);
l = []; table.textContent = `Couldn't fetch stats: ${e}`;
return;
} }
if(l.length === 0) { if(l.length === 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment