From 44924cf4ca250df2dca03a94dbaf223ec8e938e7 Mon Sep 17 00:00:00 2001 From: Christopher Teutsch Date: Tue, 6 Jun 2023 15:56:18 +0200 Subject: [PATCH] Catch errors in calendar fetching --- index.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 8b4c61b..8c73a81 100644 --- a/index.php +++ b/index.php @@ -148,8 +148,12 @@ $ical = new ICal(options: [ 'defaultWeekStart' => 'MO', 'filterDaysBefore' => '1', ]); -$ical->initUrl(ICAL_URL, userAgent: 'dorf.jetzt', acceptLanguage: 'de'); -$events = $ical->eventsFromInterval('2 week') or []; +try { + $ical->initUrl(ICAL_URL, userAgent: 'dorf.jetzt', acceptLanguage: 'de'); + $events = $ical->eventsFromInterval('2 week'); +} catch (\Exception $e){ + $events = []; +} if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']); setlocale(LC_TIME, $locale);