feat: improved error handling
This commit is contained in:
@@ -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', [
|
||||
|
||||
Reference in New Issue
Block a user