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