diff --git a/src/Controller/Booking/IndexController.php b/src/Controller/Booking/IndexController.php index d5fcae4..c7241b7 100644 --- a/src/Controller/Booking/IndexController.php +++ b/src/Controller/Booking/IndexController.php @@ -5,7 +5,9 @@ namespace App\Controller\Booking; use App\BusProNet\ApiClient; use App\BusProNet\Exception\ApiClientException; use App\BusProNet\Model\BaseData; +use App\BusProNet\Model\Notification; use App\BusProNet\XmlLoader\TravelLoader; +use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\Request; @@ -19,6 +21,7 @@ class IndexController extends AbstractController private readonly ApiClient $apiClient, private readonly TravelLoader $travelDataLoader, private readonly Security $security, + private readonly LoggerInterface $logger, ) { } @@ -38,6 +41,17 @@ class IndexController extends AbstractController $this->addFlash('error', 'Buchungen nicht abrufbar'); $bookings = new BaseData([]); } + + if ($bookings instanceof Notification) { + $this->logger->error('Unable to fetch bookings data', [ + 'code' => $bookings->code, + 'error' => $bookings->message, + ]); + + $this->addFlash('error', 'Buchungen nicht abrufbar'); + $bookings = new BaseData([]); + } + $this->travelDataLoader->patchBookings($bookings); return $this->render('booking/index.html.twig', [ diff --git a/src/Controller/PersonalDataController.php b/src/Controller/PersonalDataController.php index 7067c6a..3c2a438 100644 --- a/src/Controller/PersonalDataController.php +++ b/src/Controller/PersonalDataController.php @@ -4,6 +4,7 @@ namespace App\Controller; use App\BusProNet\ApiClient; use App\BusProNet\Exception\ApiClientException; +use App\BusProNet\Model\Notification; use App\BusProNet\Model\PersonalData; use App\Form\PersonalDataType; use Psr\Log\LoggerInterface; @@ -42,6 +43,16 @@ class PersonalDataController extends AbstractController $personalData = new PersonalData(); } + if ($personalData instanceof Notification) { + $this->logger->error('Unable to fetch personal data', [ + 'code' => $personalData->code, + 'error' => $personalData->message, + ]); + + $this->addFlash('error', 'Deine persönlichen Daten konnten nicht abgerufen werden'); + $personalData = new PersonalData(); + } + $personalDataForm = $this->createForm(PersonalDataType::class, $personalData, [ 'attr' => ['novalidate' => 'novalidate'], ]);