Skip to content

Commit f408b49

Browse files
committed
fix(serializer): throw NotNormalizableValueException if resource not found or invalid IRI
1 parent 67558d7 commit f408b49

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/Serializer/AbstractItemNormalizer.php

+2-18
Original file line numberDiff line numberDiff line change
@@ -247,29 +247,13 @@ public function denormalize(mixed $data, string $class, ?string $format = null,
247247
throw new UnexpectedValueException($e->getMessage(), $e->getCode(), $e);
248248
}
249249

250-
throw NotNormalizableValueException::createForUnexpectedDataType(
251-
\sprintf('The type of the "%s" resource "string" (IRI), "%s" given.', $resourceClass, \gettype($data)),
252-
$data,
253-
[$resourceClass],
254-
$context['deserialization_path'] ?? null,
255-
true,
256-
$e->getCode(),
257-
$e
258-
);
250+
throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" resource "string" (IRI), "%s" given.', $resourceClass, \gettype($data)), $data, [$resourceClass], $context['deserialization_path'] ?? null, true, $e->getCode(), $e);
259251
} catch (InvalidArgumentException $e) {
260252
if (!isset($context['not_normalizable_value_exceptions'])) {
261253
throw new UnexpectedValueException(\sprintf('Invalid IRI "%s".', $data), $e->getCode(), $e);
262254
}
263255

264-
throw NotNormalizableValueException::createForUnexpectedDataType(
265-
\sprintf('The type of the "%s" resource "string" (IRI), "%s" given.', $resourceClass, \gettype($data)),
266-
$data,
267-
[$resourceClass],
268-
$context['deserialization_path'] ?? null,
269-
true,
270-
$e->getCode(),
271-
$e
272-
);
256+
throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the "%s" resource "string" (IRI), "%s" given.', $resourceClass, \gettype($data)), $data, [$resourceClass], $context['deserialization_path'] ?? null, true, $e->getCode(), $e);
273257
}
274258
}
275259

0 commit comments

Comments
 (0)