feat: improved error handling and feedback

This commit is contained in:
Björn Fromme
2025-03-24 19:41:51 +01:00
parent 7bcda3e6f8
commit 296464701d
7 changed files with 64 additions and 24 deletions
+10 -2
View File
@@ -3,6 +3,9 @@
namespace App\Controller\Booking;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\ApiClientException;
use App\BusProNet\Exception\ResponseParserException;
use App\BusProNet\Model\BaseData;
use App\BusProNet\XmlLoader\TravelLoader;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
@@ -30,11 +33,16 @@ class IndexController extends AbstractController
return $this->security->logout();
}
$bookings = $this->apiClient->getBookings($bpnUser->getEmail(), $bpnUser->getPassword());
try {
$bookings = $this->apiClient->getBookings($bpnUser->getEmail(), $bpnUser->getPassword());
} catch (ApiClientException|ResponseParserException $e) {
$this->addFlash('error', 'Buchungen nicht abrufbar');
$bookings = new BaseData([]);
}
$this->travelDataLoader->patchBookings($bookings);
return $this->render('booking/index.html.twig', [
'bookings' => $bookings->getItems(),
]);
}
}
}