Skip to content

Commit eda156b

Browse files
committed
Catched the Symfony exception in the XmlDecoder
The body decoders should return null when they cannot decode the body, not throw an exception. This fixes the behavior change after the switch to the Serializer component code.
1 parent 5247d44 commit eda156b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Decoder/XmlDecoder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace FOS\RestBundle\Decoder;
1313

1414
use Symfony\Component\Serializer\Encoder\XmlEncoder;
15+
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
1516

1617
/**
1718
* Decodes XML data
@@ -34,6 +35,10 @@ public function __construct()
3435
*/
3536
public function decode($data)
3637
{
37-
return $this->encoder->decode($data, 'xml');
38+
try {
39+
return $this->encoder->decode($data, 'xml');
40+
} catch (UnexpectedValueException $e) {
41+
return null;
42+
}
3843
}
3944
}

0 commit comments

Comments
 (0)