From 8649eb49663ca6e680a503d0e5f09111891804b3 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 1 Aug 2024 20:40:45 +0200 Subject: Disable crashing on request failure --- app.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/app.js b/app.js index 387d9f0..614f977 100644 --- a/app.js +++ b/app.js @@ -48,25 +48,29 @@ for (i in profiles) { async function checkCollections() { for (i in profiles) { const p = profiles[i]; - const data = await getProfile(p); - console.log(data); - let collectionTotal = 0; - for (memberid in data.members) { - const member = data.members[memberid]; - const collectionOne = member.collection?.MYCEL; - if (collectionOne) collectionTotal += collectionOne; - } - const last = lastCollection[i]; - if (last !== collectionTotal) { - lastCollection[i] = collectionTotal; - lastCollectionGain[i] = Date.now(); - } - console.log("last: " + last); - console.log("current: " + collectionTotal); - if (Date.now() - lastCollectionGain[i] > WARN_AFTER * 1000) { - warn(p.ping) - .then((it) => it.json()) - .then(console.log, console.error); + try { + const data = await getProfile(p); + console.log(data); + let collectionTotal = 0; + for (memberid in data.members) { + const member = data.members[memberid]; + const collectionOne = member.collection?.MYCEL; + if (collectionOne) collectionTotal += collectionOne; + } + const last = lastCollection[i]; + if (last !== collectionTotal) { + lastCollection[i] = collectionTotal; + lastCollectionGain[i] = Date.now(); + } + console.log("last: " + last); + console.log("current: " + collectionTotal); + if (Date.now() - lastCollectionGain[i] > WARN_AFTER * 1000) { + warn(p.ping) + .then((it) => it.json()) + .then(console.log, console.error); + } + } catch (e) { + console.error("COULD NOTN CHECK PROFILES", e) } } } -- cgit