Use a better exception format for UTCDateTimeType

This commit is contained in:
Jan Böhmer 2024-06-10 20:17:57 +02:00
parent 1830e9da3d
commit 4d927c5870

View file

@ -28,6 +28,7 @@ use DateTimeZone;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeType; use Doctrine\DBAL\Types\DateTimeType;
use Doctrine\DBAL\Types\Exception\InvalidFormat;
/** /**
* This DateTimeType all dates to UTC, so it can be later used with the timezones. * This DateTimeType all dates to UTC, so it can be later used with the timezones.
@ -83,7 +84,11 @@ class UTCDateTimeType extends DateTimeType
); );
if (!$converted) { if (!$converted) {
throw new ConversionException("Failed to convert PHP value to a DateTime object."); throw InvalidFormat::new(
$value,
static::class,
$platform->getDateTimeFormatString(),
);
} }
return $converted; return $converted;