@@ -224,9 +224,17 @@ public function denormalize(mixed $data, string $class, ?string $format = null,
224
224
try {
225
225
return $ this ->iriConverter ->getResourceFromIri ($ data , $ context + ['fetch_data ' => true ]);
226
226
} catch (ItemNotFoundException $ e ) {
227
- throw new UnexpectedValueException ($ e ->getMessage (), $ e ->getCode (), $ e );
227
+ if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
228
+ throw new UnexpectedValueException ($ e ->getMessage (), $ e ->getCode (), $ e );
229
+ }
230
+
231
+ 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 );
228
232
} catch (InvalidArgumentException $ e ) {
229
- throw new UnexpectedValueException (\sprintf ('Invalid IRI "%s". ' , $ data ), $ e ->getCode (), $ e );
233
+ if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
234
+ throw new UnexpectedValueException (\sprintf ('Invalid IRI "%s". ' , $ data ), $ e ->getCode (), $ e );
235
+ }
236
+
237
+ 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 );
230
238
}
231
239
}
232
240
@@ -577,32 +585,14 @@ protected function denormalizeRelation(string $attributeName, ApiProperty $prope
577
585
if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
578
586
throw new UnexpectedValueException ($ e ->getMessage (), $ e ->getCode (), $ e );
579
587
}
580
- $ context ['not_normalizable_value_exceptions ' ][] = NotNormalizableValueException::createForUnexpectedDataType (
581
- $ e ->getMessage (),
582
- $ value ,
583
- [$ className ],
584
- $ context ['deserialization_path ' ] ?? null ,
585
- true ,
586
- $ e ->getCode (),
587
- $ e
588
- );
589
-
590
- return null ;
588
+
589
+ throw NotNormalizableValueException::createForUnexpectedDataType ($ e ->getMessage (), $ value , [$ className ], $ context ['deserialization_path ' ] ?? null , true , $ e ->getCode (), $ e );
591
590
} catch (InvalidArgumentException $ e ) {
592
591
if (!isset ($ context ['not_normalizable_value_exceptions ' ])) {
593
592
throw new UnexpectedValueException (\sprintf ('Invalid IRI "%s". ' , $ value ), $ e ->getCode (), $ e );
594
593
}
595
- $ context ['not_normalizable_value_exceptions ' ][] = NotNormalizableValueException::createForUnexpectedDataType (
596
- $ e ->getMessage (),
597
- $ value ,
598
- [$ className ],
599
- $ context ['deserialization_path ' ] ?? null ,
600
- true ,
601
- $ e ->getCode (),
602
- $ e
603
- );
604
-
605
- return null ;
594
+
595
+ throw NotNormalizableValueException::createForUnexpectedDataType ($ e ->getMessage (), $ value , [$ className ], $ context ['deserialization_path ' ] ?? null , true , $ e ->getCode (), $ e );
606
596
}
607
597
}
608
598
0 commit comments