Closed
Description
Here is what happens currently:
- the ChainDecoder throws a
Symfony\Component\Serializer\Exception\RuntimeException
when it cannot find a decoder for the format (and then an exception thown by the decoder being used) - the XmlEncoder throws a
Symfony\Component\Serializer\Exception\UnexpectedValueException
on failure - the JsonDecode and JsonEncoder fail silently (you get
null
as value) and then provide a method to get the json decoding error code (not the same name in them btw), which is not part of the interface (making the method hard to use as we don't have any way to access it when it is used in the serializer) - the Serializer just proxies the call to its ChainDecoder so the behavior is the same.
Both exceptions used here implement the exception interface of the component.
My suggestion is to refactor the json decoder classes to make them throw the UnexpectedValueException on failure like the xml format instead of using a separate method which cannot be accessed.
The phpdoc of the interface should also be updated to document the expected behavior on failure, which is currently not specified