From 27191c80eab80b2b8d7069646b6402511df32a12 Mon Sep 17 00:00:00 2001 From: leevi-identio Date: Wed, 19 Nov 2025 13:27:38 +0200 Subject: [PATCH 1/2] Add better error handling for fetching user reservations --- .../custom/asu_content/src/Entity/Project.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/public/modules/custom/asu_content/src/Entity/Project.php b/public/modules/custom/asu_content/src/Entity/Project.php index 0b3784356..3ba23fdbb 100644 --- a/public/modules/custom/asu_content/src/Entity/Project.php +++ b/public/modules/custom/asu_content/src/Entity/Project.php @@ -182,9 +182,19 @@ public function getUserReservations($userId): array { $request->setSender($user); $backendApi = \Drupal::service('asu_api.backendapi'); - $userReservations = $backendApi - ->send($request) - ->getContent(); + try { + $userReservations = $backendApi + ->send($request) + ->getContent(); + if(!$userReservations) { + return []; + } + return $userReservations; + } + catch (\Exception $e) { + \Drupal::logger('asu_application')->error('Error when fetching reservations for user #'.$userId); + return []; + } return $userReservations; } From 939c4242bae3594993db7dc321a923cc854c1691 Mon Sep 17 00:00:00 2001 From: leevi-identio Date: Wed, 19 Nov 2025 13:32:45 +0200 Subject: [PATCH 2/2] Fix lint errs --- public/modules/custom/asu_content/src/Entity/Project.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/modules/custom/asu_content/src/Entity/Project.php b/public/modules/custom/asu_content/src/Entity/Project.php index 3ba23fdbb..299870d34 100644 --- a/public/modules/custom/asu_content/src/Entity/Project.php +++ b/public/modules/custom/asu_content/src/Entity/Project.php @@ -186,14 +186,14 @@ public function getUserReservations($userId): array { $userReservations = $backendApi ->send($request) ->getContent(); - if(!$userReservations) { + if (!$userReservations) { return []; } return $userReservations; } catch (\Exception $e) { - \Drupal::logger('asu_application')->error('Error when fetching reservations for user #'.$userId); - return []; + \Drupal::logger('asu_application')->error('Error when fetching reservations for user #' . $userId); + return []; } return $userReservations;