feat: improved exception handling
This commit is contained in:
@@ -73,7 +73,7 @@ class EditController extends AbstractController
|
||||
// Fetch mutability information via API
|
||||
try {
|
||||
$mutableData = $this->apiClient->getMutableData($bookingData->travelId);
|
||||
} catch (ApiClientException|ResponseParserException $e) {
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', 'Reisedaten nicht (mehr) verfügbar');
|
||||
|
||||
return $this->redirectToRoute('app_bookings');
|
||||
@@ -82,7 +82,7 @@ class EditController extends AbstractController
|
||||
// Fetch availability information via API
|
||||
try {
|
||||
$availabilities = $this->apiClient->getAvailabilities($bookingData->travelId);
|
||||
} catch (ApiClientException|ResponseParserException $e) {
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', 'Reisedaten nicht (mehr) verfügbar');
|
||||
|
||||
return $this->redirectToRoute('app_bookings');
|
||||
@@ -103,36 +103,41 @@ class EditController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$response = $this->apiClient->updateBooking($formData, true);
|
||||
$this->logger->info('Initiated booking update', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
]);
|
||||
if ($response instanceof Notification) {
|
||||
if (true === $response->isError()) {
|
||||
$this->addFlash('error', $response->message);
|
||||
|
||||
try {
|
||||
$response = $this->apiClient->updateBooking($formData, true);
|
||||
if ($response instanceof Notification) {
|
||||
if (true === $response->isError()) {
|
||||
$this->addFlash('error', $response->message);
|
||||
} else {
|
||||
$this->addFlash('info', $response->message);
|
||||
}
|
||||
$this->logger->error('Booking update not successful', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
'message' => $response->message,
|
||||
]);
|
||||
} else {
|
||||
$this->addFlash('info', $response->message);
|
||||
try {
|
||||
$this->cache->delete($cacheKey);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
}
|
||||
|
||||
$this->addFlash('success', 'Buchung erfolgreich aktualisiert');
|
||||
|
||||
$this->logger->info('Booking update successful', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
||||
}
|
||||
$this->logger->error('Booking update not successful', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
'message' => $response->message,
|
||||
]);
|
||||
} else {
|
||||
try {
|
||||
$this->cache->delete($cacheKey);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
}
|
||||
|
||||
$this->addFlash('success', 'Buchung erfolgreich aktualisiert');
|
||||
|
||||
$this->logger->info('Booking update successful', [
|
||||
'email' => $bpnUser->getEmail(),
|
||||
'booking_id' => $id,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_booking_edit', ['id' => $id]);
|
||||
} catch (ApiClientException $e) {
|
||||
$this->addFlash('error', 'Es ist ein Fehler in der Kommunikation mit dem Buchungssystem aufgetreten');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user