diff --git a/src/Serializer/ItemNormalizer.php b/src/Serializer/ItemNormalizer.php index fca2bfc893c..b8c34147cf3 100644 --- a/src/Serializer/ItemNormalizer.php +++ b/src/Serializer/ItemNormalizer.php @@ -13,7 +13,8 @@ namespace ApiPlatform\Serializer; -use ApiPlatform\Exception\InvalidArgumentException; +use ApiPlatform\Exception\InvalidArgumentException as LegacyInvalidArgumentException; +use ApiPlatform\Metadata\Exception\InvalidArgumentException; use ApiPlatform\Metadata\IriConverterInterface; use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; @@ -75,7 +76,7 @@ private function updateObjectToPopulate(array $data, array &$context): void { try { $context[self::OBJECT_TO_POPULATE] = $this->iriConverter->getResourceFromIri((string) $data['id'], $context + ['fetch_data' => true]); - } catch (InvalidArgumentException) { + } catch (LegacyInvalidArgumentException|InvalidArgumentException) { $operation = $this->resourceMetadataCollectionFactory->create($context['resource_class'])->getOperation(); $uriVariables = $this->getContextUriVariables($data, $operation, $context); $iri = $this->iriConverter->getIriFromResource($context['resource_class'], UrlGeneratorInterface::ABS_PATH, $operation, ['uri_variables' => $uriVariables]);