From b788aa05b12642ebacef394238a54d11c3d64e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 11 Jun 2022 23:44:53 +0200 Subject: Handle error for user-additions salar. The script crashes just as before, but now we get slightly better error messages. --- static/user/user-additions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/static/user/user-additions.js b/static/user/user-additions.js index 0de825e8..c0579df5 100644 --- a/static/user/user-additions.js +++ b/static/user/user-additions.js @@ -34,8 +34,10 @@ window.formatters.set('description', (el, d) => { window.salar = new Promise((resolve, reject) => fetch('/static/user/salar.json') - .then(d => d.json()) - .then(d => resolve(d))) + .then(resp => { if (! resp.ok) reject("404"); else resp.json() }) + .then(d => resolve(d)) + .catch(err => reject(err)) +) window.formatters.set('location', async function(el, d) { @@ -46,7 +48,12 @@ window.formatters.set('location', async function(el, d) { return; } - let salar = await window.salar; + try { + let salar = await window.salar; + } catch (e) { + console.warn("Location formatter failed", e); + return; + } let name = m[1] let frag = salar[name]; -- cgit v1.2.3