mirror of
https://github.com/jech/galene.git
synced 2024-11-08 17:55:59 +01:00
Fix error handling in mainpage and stats.
This commit is contained in:
parent
91fa693709
commit
781bdf8c74
2 changed files with 14 additions and 5 deletions
|
@ -33,10 +33,15 @@ async function listPublicGroups() {
|
|||
|
||||
let l;
|
||||
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) {
|
||||
console.error(e);
|
||||
l = [];
|
||||
table.textContent = `Couldn't fetch groups: ${e}`;
|
||||
div.classList.remove('nogroups');
|
||||
div.classList.add('groups');
|
||||
return;
|
||||
}
|
||||
|
||||
if (l.length === 0) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue