feat: improved timeout handling for api client

This commit is contained in:
Björn Fromme
2025-11-13 11:15:31 +01:00
parent aeb25f3b7e
commit bcded403be
14 changed files with 139 additions and 14 deletions
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Controller\Booking\Create;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\TimeoutException;
use App\BusProNet\Model\Notification;
use App\Controller\Booking\Traits\BookingCreateTrait;
use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
@@ -116,6 +117,17 @@ class Step3Controller extends AbstractController
}
return $this->hxRedirect($request, $this->generateUrl('app_booking_create_step_4'));
} catch (TimeoutException $e) {
return $this->handleApiError(
'Booking inquiry timeout',
[
'exception' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
],
'Die Anfrage hat zu lange gedauert. Bitte versuchen Sie es erneut.',
$bookingCreateDto,
$form
);
} catch (\Exception $e) {
return $this->handleApiError(
'Booking inquiry exception',
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Controller\Booking\Create;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\TimeoutException;
use App\BusProNet\Model\Notification;
use App\Controller\Booking\Traits\BookingCreateTrait;
use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
@@ -94,6 +95,17 @@ class Step4Controller extends AbstractController
$this->bookingService->clearBookingCreateDto($request);
return $this->hxRedirect($request, $this->generateUrl('app_booking_create_success'));
} catch (TimeoutException $e) {
return $this->handleApiError(
'Booking creation timeout',
[
'exception' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
],
'Die Anfrage hat zu lange gedauert. Bitte versuchen Sie es erneut.',
$bookingCreateDto,
$form
);
} catch (\Exception $e) {
return $this->handleApiError(
'Booking creation exception',
@@ -7,6 +7,7 @@ namespace App\Controller\Booking\Edit;
use App\BusProNet\ApiClient;
use App\BusProNet\DataProcessor\BookingDataProcessor;
use App\BusProNet\Exception\ApiClientException;
use App\BusProNet\Exception\TimeoutException;
use App\BusProNet\Model\Notification;
use App\Controller\Booking\Traits;
use App\Controller\Booking\Traits\BookingDataTrait;
@@ -146,6 +147,13 @@ class IndexController extends AbstractController
return $this->hxRedirect($request, $this->generateUrl('app_booking_edit', ['id' => $id]));
}
} catch (TimeoutException $e) {
$this->addFlash('error', 'Die Anfrage hat zu lange gedauert. Bitte versuchen Sie es erneut.');
$this->logger->error('Booking update timeout', [
'email' => $email,
'booking_id' => $id,
'exception' => $e->getMessage(),
]);
} catch (ApiClientException $e) {
$this->addFlash('error', 'Es ist ein Fehler in der Kommunikation mit dem Buchungssystem aufgetreten');
}