feat: improved error handling of xml parsers and loaders
This commit is contained in:
@@ -12,6 +12,9 @@ use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\XmlLoader\HotelLoader;
|
||||
use App\BusProNet\XmlLoader\PickupLoader;
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\Exception\HotelNotFoundException;
|
||||
use App\Exception\HotelNotInTravelException;
|
||||
use App\Exception\TravelNotFoundException;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
@@ -101,15 +104,6 @@ class TravelDataService
|
||||
try {
|
||||
$travel = $this->travelLoader->loadById($dateId, $hotelId);
|
||||
|
||||
if (null === $travel) {
|
||||
$this->logger->debug('Travel not found in XML', [
|
||||
'dateId' => $dateId,
|
||||
'hotelId' => $hotelId,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->enrichTravelData($travel);
|
||||
$this->logger->debug('Travel data loaded from XML', [
|
||||
'dateId' => $dateId,
|
||||
@@ -118,6 +112,20 @@ class TravelDataService
|
||||
]);
|
||||
|
||||
return $travel;
|
||||
} catch (TravelNotFoundException $e) {
|
||||
$this->logger->debug('Travel not found in XML', [
|
||||
'dateId' => $dateId,
|
||||
'hotelId' => $hotelId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
throw $e;
|
||||
} catch (HotelNotFoundException | HotelNotInTravelException $e) {
|
||||
$this->logger->debug('Hotel not found in XML', [
|
||||
'dateId' => $dateId,
|
||||
'hotelId' => $hotelId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
throw $e;
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error('Failed to load travel data from XML', [
|
||||
'dateId' => $dateId,
|
||||
|
||||
Reference in New Issue
Block a user