1
0
mirror of https://github.com/dwaxweiler/connector-mobilizon synced 2025-06-05 21:59:25 +02:00

add error handling

This commit is contained in:
Daniel Waxweiler
2023-05-07 21:48:33 +02:00
parent 091317a532
commit d79a0cf9a6
9 changed files with 111 additions and 29 deletions

View File

@ -29,19 +29,26 @@ class EventsListWidget extends \WP_Widget {
$eventsCount = $options['eventsCount'];
$groupName = isset($options['groupName']) ? $options['groupName'] : '';
if ($groupName) {
$data = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName);
} else {
$data = GraphQlClient::get_upcoming_events($url, (int) $eventsCount);
try {
if ($groupName) {
$data = GraphQlClient::get_upcoming_events_by_group_name($url, (int) $eventsCount, $groupName);
} else {
$data = GraphQlClient::get_upcoming_events($url, (int) $eventsCount);
}
$events = $data['data']['events']['elements'];
$classNamePrefix = NAME;
$locale = get_locale();
$isShortOffsetNameShown = Settings::isShortOffsetNameShown();
$timeZone = wp_timezone_string();
require dirname(__DIR__) . '/view/events-list.php';
} catch (GeneralException $e) {
require dirname(__DIR__) . '/view/events-list-not-loaded.php';
} catch (GroupNotFoundException $e) {
require dirname(__DIR__) . '/view/events-list-group-not-found.php';
}
$classNamePrefix = NAME;
$locale = get_locale();
$isShortOffsetNameShown = Settings::isShortOffsetNameShown();
$timeZone = wp_timezone_string();
require dirname(__DIR__) . '/view/events-list.php';
echo $args['after_widget'];
}