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
+11 -6
View File
@@ -3,6 +3,8 @@
namespace App\Controller\Booking;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\ApiClientException;
use App\BusProNet\Exception\ResponseParserException;
use App\BusProNet\Model\Notification;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -56,13 +58,16 @@ class DownloadController extends AbstractController
'booking_id' => $id,
]);
$file = $this
->apiClient
->getDocuments($bpnUser->getEmail(), $bpnUser->getPassword(), $id, $type)
;
try {
$file = $this
->apiClient
->getDocuments($bpnUser->getEmail(), $bpnUser->getPassword(), $id, $type);
} catch (ApiClientException|ResponseParserException $e) {
$file = null;
}
if (null === $file || $file instanceof Notification) {
$this->addFlash('error', 'Keine Dokumente vorhanden');
$this->addFlash('error', 'Keine Dokumente vorhanden oder nicht abrufbar');
return $this->redirectToRoute('app_bookings');
}
@@ -84,4 +89,4 @@ class DownloadController extends AbstractController
return $response;
}
}
}