The error handling is inconsistent in the serializer decoders #9393
Labels
Enhancement
Good first issue
Ideal for your first contribution! (some Symfony experience may be required)
Serializer
Here is what happens currently:
Symfony\Component\Serializer\Exception\RuntimeException
when it cannot find a decoder for the format (and then an exception thown by the decoder being used)Symfony\Component\Serializer\Exception\UnexpectedValueException
on failurenull
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)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
The text was updated successfully, but these errors were encountered: