merge staging to production #58

Merged
hauke merged 17 commits from staging into production 2026-08-27 21:35:38 +02:00
Showing only changes of commit 4545852327 - Show all commits

Report errors while loading the calendar

The response of the fetch went to the parser without ever looking at it. When
the calendar could not be loaded the error page of the web server was parsed as
a calendar, which threw inside a promise nobody was waiting on. The result was
an empty table, an unhandled rejection in the console and an error message
about broken calendar syntax that says nothing about the actual problem, a
calendar that is not there.

Refuse a response that is not ok, naming the status, and log failures in the
chain, like the calendar page already does.

  before: Uncaught (in promise) Error: invalid line (no token ";" or ":")
                                       "<html>404 Not Found</html>"
  after:  Fehler beim Laden der Termine:
          Error: /calendars/all.ics: 404 Not Found

The table stays empty either way, there is nothing to show without a calendar.

Fixes: c28f04c6e8 ("switch to ics files; make calendars work; fix some minor issues")
Assisted-by: Claude:claude-opus-5
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Hauke Mehrtens 2026-08-22 19:58:02 +02:00

View file

@ -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));
});