diff --git a/static/js/upcoming.js b/static/js/upcoming.js index c452467..0e2e266 100644 --- a/static/js/upcoming.js +++ b/static/js/upcoming.js @@ -101,7 +101,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"); @@ -138,5 +146,6 @@ document.addEventListener("DOMContentLoaded", () => { table.appendChild(row); }); - }); + }) + .catch(err => console.error("Fehler beim Laden der Termine:", err)); });