feat: improved error handling and feedback
This commit is contained in:
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user