feat: improved error handling of xml parsers and loaders

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 0f6b73340e
commit 4f02529b15
9 changed files with 257 additions and 42 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace App\Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Exception thrown when attempting to load hotel data that does not exist.
*
* This exception is used when a hotel ID cannot be found in the
* available hotel data sources.
*/
class HotelNotFoundException extends HttpException
{
public function __construct(int $hotelId, ?\Throwable $previous = null)
{
$message = sprintf(
'Hotel not found for hotel ID %d',
$hotelId
);
parent::__construct(404, $message, $previous);
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace App\Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Exception thrown when attempting to load a hotel that exists but is not available for the specified travel.
*
* This exception is used when a hotel ID exists in the system but is not
* associated with the requested travel/date ID.
*/
class HotelNotInTravelException extends HttpException
{
public function __construct(int $dateId, int $hotelId, ?\Throwable $previous = null)
{
$message = sprintf(
'Hotel ID %d is not available for travel ID %d',
$hotelId,
$dateId
);
parent::__construct(404, $message, $previous);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace App\Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Exception thrown when attempting to load travel data that does not exist.
*
* This exception is used when a travel/date ID cannot be found in the
* available travel data sources (XML files or API).
*/
class TravelNotFoundException extends HttpException
{
public function __construct(int $dateId, ?\Throwable $previous = null)
{
$message = sprintf(
'Travel data not found for date ID %d',
$dateId
);
parent::__construct(404, $message, $previous);
}
}