diff --git a/static/js/upcoming.js b/static/js/upcoming.js index 64daf96..d978c7e 100644 --- a/static/js/upcoming.js +++ b/static/js/upcoming.js @@ -206,7 +206,15 @@ document.addEventListener("DOMContentLoaded", () => { const table = document.getElementById("upcoming"); fetch(ics) - .then(response => response.text()) + .then(response => { + // Without this an error page would be handed to the parser below, which + // then fails with a confusing complaint about the calendar syntax. + if (!response.ok) { + throw new Error(`${ics}: ${response.status} ${response.statusText}`); + } + + return response.text(); + }) .then(icsText => { getUpcomingEvents(icsText, now, max_items, max_days).forEach(event => { const row = document.createElement("tr"); @@ -246,5 +254,6 @@ document.addEventListener("DOMContentLoaded", () => { table.appendChild(row); }); - }); + }) + .catch(err => console.error("Fehler beim Laden der Termine:", err)); });