Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f816628

Browse files
committed
[Serializer] Fix wrong InvalidArgumentException
1 parent 6b34c00 commit f816628

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Serializer\Normalizer;
1313

14-
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException;
14+
use Symfony\Component\PropertyAccess\Exception\InvalidArgumentException as PropertyAccessInvalidArgumentException;
1515
use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException;
1616
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
1717
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
@@ -20,6 +20,7 @@
2020
use Symfony\Component\Serializer\Encoder\JsonEncoder;
2121
use Symfony\Component\Serializer\Encoder\XmlEncoder;
2222
use Symfony\Component\Serializer\Exception\ExtraAttributesException;
23+
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
2324
use Symfony\Component\Serializer\Exception\LogicException;
2425
use Symfony\Component\Serializer\Exception\MissingConstructorArgumentsException;
2526
use Symfony\Component\Serializer\Exception\NotNormalizableValueException;
@@ -409,7 +410,7 @@ public function denormalize($data, string $type, string $format = null, array $c
409410

410411
try {
411412
$this->setAttributeValue($object, $attribute, $value, $format, $attributeContext);
412-
} catch (InvalidArgumentException $e) {
413+
} catch (PropertyAccessInvalidArgumentException $e) {
413414
$exception = NotNormalizableValueException::createForUnexpectedDataType(
414415
sprintf('Failed to denormalize attribute "%s" value for class "%s": '.$e->getMessage(), $attribute, $type),
415416
$data,

0 commit comments

Comments
 (0)