Catch errors in calendar fetching

This commit is contained in:
Christopher Teutsch 2023-06-06 15:56:18 +02:00
parent 0adc7964e0
commit 44924cf4ca

View File

@ -148,8 +148,12 @@ $ical = new ICal(options: [
'defaultWeekStart' => 'MO',
'filterDaysBefore' => '1',
]);
try {
$ical->initUrl(ICAL_URL, userAgent: 'dorf.jetzt', acceptLanguage: 'de');
$events = $ical->eventsFromInterval('2 week') or [];
$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);