feat: improved error handling
This commit is contained in:
@@ -5,7 +5,9 @@ namespace App\Controller\Booking;
|
|||||||
use App\BusProNet\ApiClient;
|
use App\BusProNet\ApiClient;
|
||||||
use App\BusProNet\Exception\ApiClientException;
|
use App\BusProNet\Exception\ApiClientException;
|
||||||
use App\BusProNet\Model\BaseData;
|
use App\BusProNet\Model\BaseData;
|
||||||
|
use App\BusProNet\Model\Notification;
|
||||||
use App\BusProNet\XmlLoader\TravelLoader;
|
use App\BusProNet\XmlLoader\TravelLoader;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -19,6 +21,7 @@ class IndexController extends AbstractController
|
|||||||
private readonly ApiClient $apiClient,
|
private readonly ApiClient $apiClient,
|
||||||
private readonly TravelLoader $travelDataLoader,
|
private readonly TravelLoader $travelDataLoader,
|
||||||
private readonly Security $security,
|
private readonly Security $security,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +41,17 @@ class IndexController extends AbstractController
|
|||||||
$this->addFlash('error', 'Buchungen nicht abrufbar');
|
$this->addFlash('error', 'Buchungen nicht abrufbar');
|
||||||
$bookings = new BaseData([]);
|
$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);
|
$this->travelDataLoader->patchBookings($bookings);
|
||||||
|
|
||||||
return $this->render('booking/index.html.twig', [
|
return $this->render('booking/index.html.twig', [
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\BusProNet\ApiClient;
|
use App\BusProNet\ApiClient;
|
||||||
use App\BusProNet\Exception\ApiClientException;
|
use App\BusProNet\Exception\ApiClientException;
|
||||||
|
use App\BusProNet\Model\Notification;
|
||||||
use App\BusProNet\Model\PersonalData;
|
use App\BusProNet\Model\PersonalData;
|
||||||
use App\Form\PersonalDataType;
|
use App\Form\PersonalDataType;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@@ -42,6 +43,16 @@ class PersonalDataController extends AbstractController
|
|||||||
$personalData = new PersonalData();
|
$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, [
|
$personalDataForm = $this->createForm(PersonalDataType::class, $personalData, [
|
||||||
'attr' => ['novalidate' => 'novalidate'],
|
'attr' => ['novalidate' => 'novalidate'],
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user