aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-11 23:44:53 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-06-12 00:11:33 +0200
commitb788aa05b12642ebacef394238a54d11c3d64e09 (patch)
treeaaffd8b9c334d10199be024a4338e640aa01b9e6
parentUpdate remaining routse to new xml or html system. (diff)
downloadcalp-b788aa05b12642ebacef394238a54d11c3d64e09.tar.gz
calp-b788aa05b12642ebacef394238a54d11c3d64e09.tar.xz
Handle error for user-additions salar.
The script crashes just as before, but now we get slightly better error messages.
-rw-r--r--static/user/user-additions.js13
1 files 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];